Analysis: Mathematics: Subtract Straight Line
Subtract straight line from a data plot
subtract_line x1:=0 y1:=0.5 x2:=200 y2:=3.5;
Please refer to the page for additional option switches when accessing the x-function from script
Input
XYRange
Specifies the input data that will be subtracted.
double
Specifies the X value of the first point.
Specifies the Y value of the first point.
Specifies the X value of the second point.
Specifies the Y value of the second point.
Output
Specifies the output range for the subtracted data.
See the syntax here.
This X-Function can be used to subtract a straight line from a data set. The straight line is determined by two points. If you use this X-Function from the menu and a graph is active, you can click on the graph to select these two points. If you use this X-Function from script, you can specify the X and Y values of these two points.
// In this example of the subtract_line X-Function, we will subtract a straight line created by the endpoints of a curve // Import our sample dataset newbook; path$ = system.path.program$ + "Samples\Spectroscopy\Raman Baseline.dat"; impasc fname:=path$; // define ranges for X and Y and an XY range range rx = 1; range ry = 2; range rxy = (1,2); range rxynew = (3,4); // columns do not exist yet // Plot our data plotxy rxy plot:=201 color:=color(blue); // Use the X and Y ranges to get the endpoints and subtract into new columns and plot subtract_line iy:=rxy x1:=rx[1] y1:=ry[1] x2:=rx[rx.nrows] y2:=ry[ry.nrows] oy:=<new>; plotxy rxynew color:=color(orange) plot:=201 ogl:=1; // Add the line used for subtraction - before and after subtracting draw -n subline1 -l {rx[1],ry[1],rx[rx.nrows],ry[ry.nrows]}; subline1.color=2; draw -n subline2 -l {rx[1],0,rx[rx.nrows],0}; subline2.color=1;
subtract_ref
Keywords:baseline correction, subtraction