Pick XY data points from a 2D graph.
Minimum Origin Version Required: 8.1 SR3
Command Line Usage
1. pickpts npts:=3;
2. pickpts gp:=[Graph2] npts:=5 plot:=<new>;
X-Function Execution Options
Please refer to the page for additional option switches when accessing the x-function from script
|| Specifies the graph to pick points from
|Number of Points to Get
|| Specifies the number of points to pick from the input graph
|| Specifies the type for picking points
- data:Data Reader
- Picks points in Data Reader mode. It only picks up data points existed in the source worksheet.
- screen:Screen Reader
- Picks points in Screen Reader mode. It allows you to pick up points located anywhere on the graph and reads their XY coordinates from graph.
|| Specifies the output range for picked points’ X coordinates.
|| Specifies the output range for picked points’ Y coordinates
|| Specifies the output range for plot name(s) of the picked data points. It is accessible only when Data Reader is selected for Reader Type.
|| Specifies the output range for data points’ indices. It is accessible only when Data Reader is selected for Reader Type.
This X-Function allows you to pick XY data points from a graph using the Data Reader type or Screen Reader type and gets related coordinate information.
Starting with Origin 2018 SR0, there is a GUI tool that uses the pickpts X-Function. The tool is opened by right-clicking on the data point tooltip that shows when you mouse over a data point in a line, scatter, line + symbol or column/bar chart.
The following scripts shows how to pick data points from multiple layers.
Output pickpts data to new sheet
// create a new worksheet window based on ORIGIN.OTW
// fill the worksheet with row numbers in the first two columns
col(A) = data(1,10);
col(B) = data(1,10);
// fill the third and forth columns with normal random numbers
col(C) = Normal(10);
col(D) = Normal(10);
// highlight second to forth columns
worksheet -s 2 0 4 0;
// plot a 3Ys_Y-Y-Y graph from the selected three columns
// pick up 5 points from graph, and output their XY coordinates, plot names and indices
pickpts npts:=5 plot:=<new> index:=<new>;
With the graph active, double-click on data points of interest to select them:
After the selection is done, the results are automatically output to a new worksheet:
Output data to existing sheet
In this example, we have a three panel (layer) graph, with each layer containing a plot of Assymmetric Gaussian data. We use pickpts to pick the peak point in each and output the result to Book2. Note that we are using a variable of type StringArray to store and output the plot names. Also, see StringArray (object).
// create datasets dsx and dsy
dataset dsx, dsy;
// create StringArray dsn
// call the pickpts X-Function, use Data Reader to pick 3 points.
// Put X coordinates in dsx, y coordinates in dsy, point index in dsi, and plot name in dsn
pickpts npts:=3 type:=data x:=dsx y:=dsy index:=dsi plot:=dsn;
// define output sheet range with 4 columns
range wks = [Book2]Sheet1!;
// assign long names to each column
wks.col1.lname$ = X Coordinate;
wks.col2.lname$ = Y Coordinate;
wks.col3.lname$ = Plot Name;
wks.col4.lname$ = Point Index;
// create range variables for each output variable
range aa = [Book2]1!1;
range bb = [Book2]1!2;
range cc = [Book2]1!3;
range dd = [Book2]1!4;
// output coordinate and index values to Book2
aa = dsx;
bb = dsy;
dd = dsi;
// copy StringArray dsn to range cc ([Book2]1!3;)
|Note: Since Origin 2017 SR0, we can also use a variable of type Dataset to store and output the plot name. For instance, we can change the above example as follows:
- Create a Text & Numberic dataset dsn to store the plot name.
//Create a Text & Numberic dataset instead of using StringArry
dataset -a dsn;
- After pick the points, then output the plot name to Book2 directly.
//Output the plot name directly instead of using the CopyTo method.
cc = dsn;