Fill Area Under Intersection of Two Curves

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.

Post1879_11

  1. Go to Data folder, Highlight col(A)~col(D) and plot a line graph.
  2. Double click the plot to open Plot Details dialog.
  3. 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,

  1. Go to Group tab and set Edit Mode to be Independent so we can control Fill area for each plot separately
  2. Select the 2nd plot under Layer1 on left panel,
  3. Go to Line tab and uncheck Fill Area under Curve. Click Apply button.
  4. Select the 1st plot under Layer1 on left panel. Go to Pattern tab to customize the fill color and transparency.
Post1879_09 Post1879_10

 

You can also fill area between two curves.

Post1879_15

  1. Open the Plot Details dialog and with 1st plot selected on the left panel, go to Line tab again.
  2. 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.

Post1879_13 Post1879_14

 

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 interpolationset 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.

Post1879_06

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.

Post1879_07

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.

About S Z

Male, single, alive.

View all posts by S Z →

4 Comments on “Fill Area Under Intersection of Two Curves”

  1. This is way over complicated. I solved this by doing the following:
    1) normalizing the intensity of the UV and Fluorescence in Origin
    2) taking the minimum of both the UV and Fluorescence and plotting it as a line
    3) shading below the line.
    Here are the steps to get it working on yours:
    1) Have the wavelength in 1st column, UV in 2nd, and Fluorescence in 3rd column.
    2) Create three empty columns to the left and look to see what the column is labeled as for UV and Fluoro.
    2b) Typically the UV is column A and the Fluoro is column B
    3) type this equation into the 4th column to normalize the UV (divide the value by the maximum value): (col(A)/(max(col(A)))
    4) do the same equation for the 5th column to normalize the Fluoro (just make sure that you have correct columns): col(B)/(max(col(B)))
    5) In the final column we need to take the minimum of each of the normalized columns by using the following F(x): min(col(C),col(D))
    Now plot the normalized data with the minimum data and shade underneath the minimum data. Super simple.

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です