This post will show you how to fill area under intersection of two curves such as follows. This only shade the area. If you want to calculate the area, please use Gadget: Integrate… menu, which also adds shade but the shade color isn’t customizable.
The following discussions/screenshots are all based on Origin2015, but some features involved are also available in earlier versions.
Feel free to download the sample data: Fill Area Under Curves.zip.
First, let’s see how to fill area under a curve.
- Go to Data folder, Highlight col(A)~col(D) and plot a line graph.
- Double click the plot to open Plot Details dialog.
- Go to Line tab and check Fill Area Under Curve checkbox and click Apply button.
Areas under both curves are shaded. This is because when multiple Y data are plotted together, they are grouped so the setting for 1st plot will be applied to settings for members of the group.
To fill area under the black curve only,
- Go to Group tab and set Edit Mode to be Independent so we can control Fill area for each plot separately.
- Select the 2nd plot under Layer1 on left panel,
- Go to Line tab and uncheck Fill Area under Curve. Click Apply button.
- Select the 1st plot under Layer1 on left panel. Go to Pattern tab to customize the fill color and transparency.
You can also fill area between two curves.
- Open the Plot Details dialog and with 1st plot selected on the left panel, go to Line tab again.
- This time, choose Fill to next data plot – Above Below Colors for the combo box.
Note: If the two curves are not next to each other on the left panel, you will need to go to Layer Contents dialog to move them together first.
The previous Pattern tab becomes Pattern_Above and an extra Pattern_Below tab appears as well. Pattern_Above controls the area where next plot (red curve) is above current plot (black). Pattern_Below tab controls the area where next plot is below the current plot. In this example, we set Fill color on Pattern_Above tab to None.
Now let’s try to shade the area under the intersection of both curves
There is no straightforward way. But basically we are trying to shade the area under minimum value of both curves in common region. We can use interpolation 、 set column values features in Origin to get a new data with min values of both curves. Then plot that into existing graph and shade area below it.
The two data have different X data. To find the common X range, add a new column in the worksheet and set the column as X. Open Set Value dialog and set the formula as follows.
In the dialog above, in Before Formula Scripts: define two range variable rx1 and rx2 for the two X data. Calculate the minimum and maximum X value of the two ranges: Xmin and Xmax. In Formula box, Use data function to generate a numeric sequence with step length 1.
Then use Analysis: Mathematics: Interpolate/Extrapolate Y from X tool to do linear interpolate the two Y data in the shared X region. Then in col(H), get minimum value of the two interpolated Y data.
Add col(H) into existing graph. Open Plot Details dialog, and fill area under this new data to get the final graph. See Graph1 window in Graph folder of the project.