Shade Different Areas Under a Curve

rjbinney

Active Member
Joined
Dec 20, 2010
Messages
292
Office Version
  1. 365
Platform
  1. Windows
I KNEW I shouldn't have slept through calculus!

I would like a generic S-curve, but I'd like to color in under the curve. I have figured out how to color the entire area under the curve:
Excel 2016 (Windows) 32 bit
[TABLE="class: head"]
<tbody>[TR="bgcolor: #888888"]
[TH][/TH]
[TH]
A
[/TH]
[TH]
B
[/TH]
[TH]
C
[/TH]
[TH]
D
[/TH]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
3
[/TD]
[TD][/TD]
[TD][/TD]
[TD]Rev X[/TD]
[TD]Area[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
4
[/TD]
[TD]X[/TD]
[TD]Y[/TD]
[TD]
0​
[/TD]
[TD]
0​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
5
[/TD]
[TD]
-5​
[/TD]
[TD]
0.006693​
[/TD]
[TD]
0​
[/TD]
[TD]
0.006693​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
6
[/TD]
[TD]
-4​
[/TD]
[TD]
0.017986​
[/TD]
[TD]
83.33333​
[/TD]
[TD]
0.017986​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
7
[/TD]
[TD]
-3​
[/TD]
[TD]
0.047426​
[/TD]
[TD]
166.6667​
[/TD]
[TD]
0.047426​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
8
[/TD]
[TD]
-2​
[/TD]
[TD]
0.119203​
[/TD]
[TD]
250​
[/TD]
[TD]
0.119203​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
9
[/TD]
[TD]
-1​
[/TD]
[TD]
0.268941​
[/TD]
[TD]
333.3333​
[/TD]
[TD]
0.268941​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
10
[/TD]
[TD]
0​
[/TD]
[TD]
0.5​
[/TD]
[TD]
416.6667​
[/TD]
[TD]
0.5​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
11
[/TD]
[TD]
1​
[/TD]
[TD]
0.731059​
[/TD]
[TD]
500​
[/TD]
[TD]
0.731059​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
12
[/TD]
[TD]
2​
[/TD]
[TD]
0.880797​
[/TD]
[TD]
583.3333​
[/TD]
[TD]
0.880797​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
13
[/TD]
[TD]
3​
[/TD]
[TD]
0.952574​
[/TD]
[TD]
666.6667​
[/TD]
[TD]
0.952574​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
14
[/TD]
[TD]
4​
[/TD]
[TD]
0.982014​
[/TD]
[TD]
750​
[/TD]
[TD]
0.982014​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
15
[/TD]
[TD]
5​
[/TD]
[TD]
0.993307​
[/TD]
[TD]
833.3333​
[/TD]
[TD]
0.993307​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
16
[/TD]
[TD]
6​
[/TD]
[TD]
0.997527​
[/TD]
[TD]
916.6667​
[/TD]
[TD]
0.997527​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
17
[/TD]
[TD]
7​
[/TD]
[TD]
0.999089​
[/TD]
[TD]
1000​
[/TD]
[TD]
0.999089​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
18
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
19
[/TD]
[TD]
-5​
[/TD]
[TD]Min[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
20
[/TD]
[TD]
7​
[/TD]
[TD]Max[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="class: grid"]
<tbody>[TR]
[TD]Sheet: Sheet1[/TD]
[/TR]
</tbody>[/TABLE]

Where Column B=1/(1+EXP(-A))
Column C = 1000 * (A- MIN(A:A)) / (MAX(A:A)-MIN(A:A))

Which gives me:
Curve.png



What I'd like to do is have multiple colors under the curve:
COlored%20Curve.png
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Thanks. That second link is where I got the formula to attempt the original. Trouble is, the curve is a function of the length, so if you just "cut off" the formula at a certain X, it throws the whole curve off. I may just have to plot the curve and manually fill it in.
 
Upvote 0
Your first attempt followed my tutorial Fill Under or Between Series in an Excel XY Chart, summarized below.

The first two columns of data are the X-Y coordinates of the curve to fill under, the values below the table are the minimum and maximum of the horizontal axis, and the third and fourth columns are the data for the area chart series that fills below the curve. Note that the first and last X values for the area chart data are repeated, and the first and last Y values for the area chart are zero; these features ensure a vertical edge on the left and right.

Select the first two columns and create an XY chart (top left chart). Copy the next two columns, select the chart, and use Paste Special to add the data as a new series, series in columns, first column has X data, first row has series names (top center chart). Format the new series, and select Secondary Axis (top right chart).

Right click the new series, choose Change Series Chart Type, and select Area Chart (middle left chart). Add a secondary horizontal axis (middle center chart). Convert secondary horizontal axis to a date-scale (middle right chart).

Hide the secondary horizontal axis: format so it uses no line, has no axis tick labels and no axis tick marks (bottom left chart). Delete the secondary vertical axis (bottom center chart).

45c3RO1.png


It's the same for multiple fill regions. Here is the data and the three individual filled regions under the curve. Not in addition to min and max below the data table, there is also the two X values where the different colored fill regions meet. They are here for reference and are not used in any formulas, although they could be if you wanted to get clever. Not only are the first and last X values repeated, but so are the X values where the fill colors change. There are three columns with area chart Y values for the three series we will have to add, and note that each range of nonzero values is surrounded by zeros.

6h7ac5Z.png


The protocol is the same as for one fill region.

Select the first two columns and create an XY chart (top left chart). Copy the next four columns, select the chart, and use Paste Special to add the data as new series, series in columns, first column has X data, first row has series names (top center chart). Format the three new series, and select Secondary Axis (top right chart).

Right click each new series, choose Change Series Chart Type, and select Area Chart (middle left chart). Add a secondary horizontal axis (middle center chart). Convert secondary horizontal axis to a date-scale (middle right chart).

Hide the secondary horizontal axis: format so it uses no line, has no axis tick labels and no axis tick marks (bottom left chart). Delete the secondary vertical axis (bottom center chart).

kjd2Nl2.png
 
Upvote 0
What color do you use for Mind. BLOWN!!! ?

Thanks, will play with this tonight.

Thank you!
 
Upvote 0
The Max cell threw me at first, until I realized it was the max X of the graph, and Excel will change the maximum of the x axis as you modify the data. So you need to watch the X axis and be ready to change Max to match the graph.
I now have the graph I want, so BIG thank you!! RAK_da_Pira.
 
Upvote 0

Forum statistics

Threads
1,223,630
Messages
6,173,457
Members
452,515
Latest member
nguyenkim

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top