2.10.37 plotxy

Brief Information

Create plot from XY data by specifying plot type and properties

Additional Information

Minimum Origin Version Required: Origin 8 SR0, updated in Origin 8.5.1 SR0. The option to hide the created graph is available starting with 9.0.

Command Line Usage

1. plotxy iy:=(1,2);
2. plotxy iy:=(1,2,3);  // Plot col(2) with col(3) as error bar
3. plotxy iy:=[Book1]2!(1,3) o:=[Graph1]1!;
4. plotxy (?,1:end);
5. plotxy [Book1]2!(#, 3);
6. plotxy (1:3)!(1,2) plot:=200; // Plot col(2) of the 1~3 sheet in the active workbook.
7. plotxy ((1,2[1:6]),(1,2[7:12]),(1,2[13:18])) plot:=202 ogl:=[<new template:=doubley name:=SamplePlot>]; 
    // Plot 3 ranges of col(2) into a specified graph template and name the graph as SamplePlot.
8. plotxy (1,3) ogl:=2; // Plot the col(3) into layer 2.
9. plotxy (1,2) plot:=186 ogl:=<new template:=PolarXrYTheta>;  // Polar r(X) theta(Y)
10. plotxy (1,2) plot:=192 ogl:=<new template:=Polar>;  // Polar theta(X) r(Y)
11. plotxy iy:=[Book2]"Sheet1"!(Col(1),Col(5)[60]:Col(8)[80]) plot:=200 ogl:=[Graph11]1!; 
    //showing how to plot data from column 5, row 60 to column 8, row 80

X-Function Execution Options

Please refer to the page for additional option switches when accessing the x-function from script

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Input iy

Input

XYRange

<active>

Specifies the input data, including X column, Y column, Y error column.

Plot Type plot

Input

int

201

Specifies the plot type. The most common are 200, line; 201, scatter; 202, line + symbol. For the list of all plot types, see Plot Type IDs. Note: only the plot types for XY range can be used.

Symbol Size (Pts) size

Input

double

-1

Specifies the symbol size in points. Here the default value is -1, which means that the size will always follow the symbol size specified in the template automatically.

Rescale rescale

Input

int

1

Specifies whether to rescale the graph (1) or not (0).

Legend legend

Input

int

1

Specifies whether to generate the legend on graph.
legend:=0 option only works if a template does NOT have a saved Legend object.
legend:=1 generates a legend in regardless whether the template has a Legend or not.

Plot Color color

Input

int

0

Specifies the color of plots. This only works on Line, Symbol and Line+Symbol graphs. Color may be an index into Origin's Color List : 1 (Black), 2 (Red), up to 24 (Dark Gray) or up to 40 if you have defined the 16 Custom Colors in the Color dialog. Additionally, you can use the color function to assign any RGB color, as in
plotxy iy:=(1,2) plot:=200 color:=color(240,208,0)

Hide Newly Created Graph hide

Input

int

0
Specify whether to hide the newly created graph (1) or not (0).
Layer to Plot into ogl

Output

GraphLayer

<new>

Specifies the graph layer to add plots.

Use range syntax.

Description

This function plots data from specified range, which can include Y error column. You can specify the plot type and symbol size. You can also specify whether to show the legend and whether to rescale the graph.

Examples

  • There are special notation '?' and '#' in the range as the parameter. '?' indicates that the range is forced to use worksheet designation, and will fail if the range designation does not satisfy the requirement, and '#' means that the range ignores designations and use row number as X designation. For example,
plotxy (?, 5);  // if col(5) happens to be X column call fails
plotxy (#, 3);  // plot col(3) as Y and use row number as X
  • To make a plot with Y error, one more column can be added into the input range as Y error. For example:
plotxy iy:=(1, 2, 3);  // plot col(2) vs col(1), with col(3) as Y error
  • The built-in specialized graph templates can be also used to make plots. For example:
// plot polar graph
plotxy (1,2) plot:=186 ogl:=<new template:=PolarXrYTheta>;  // Polar r(X) theta(Y)
plotxy (1,2) plot:=192 ogl:=<new template:=Polar>;  // Polar theta(X) r(Y)
  • The following example shows how to add a curve into specified graph layer.
newbook;
string fn$ = System.path.program$ + "Samples\Curve Fitting\Exponential Decay.dat";
impasc fn$;
string bn$ = %H;
int nCols = wks.ncols;
win -t Plot;	// Create an empty plot
loop (ii, 2, nCols)
{
	// Add dataset into a layer
	plotxy [bn$]1!$(ii) plot:=201 rescale:=1 color:=ii ogl:=!1;
}
// Group the curves
layer -g;
  • The following example shows how to plot a 3D waterfall graph, you can use set command to control the color mapping.
// plot waterfall graph
plotxy iy:=(1,2:4) plot:=210 ogl:=<new template:=glWater3D>; 
//Y color mapping
plotxy iy:=(1,2:4) plot:=210 ogl:=<new template:=glWater3D>;
set %C -LGCB 0;	
//Z color mapping
plotxy iy:=(1,2:4) plot:=210 ogl:=<new template:=glWater3D>;
set %C -LGCB 3;
  • Sample Code
// Start with a new Book
newbook;
col(1) = data(1,30);
col(2) = normal(30);
col(3) = uniform(30); // Auto-creation of column 3
// Remember Book and Sheet names
string bkname$ = page.name$;
string shname$ = layer.name$;

// Since sheet is active, we can specify column range
plotxy (1,2:3);

// Remember ranges within our Book and Sheet
range r1 = [bkname$]shname$!3[1:15];
range r2 = [bkname$]shname$!3[16:end];
// Now that graph is active window, need to specify Book and Sheet
plotxy [bkname$]shname$!((2[1:15]),(2[16:30])); // Creates second layer
// or use range which knows its Book and Sheet
plotxy iy:=r1 ogl:=2;
plotxy iy:=r2 ogl:=2;

page.active = 2;
color = 1;
doc -e DY {
   set %C -c $(color);
   color++;
}
layarrange row:=2 col:=1 ygap:=7 left:=12 right:=12 top:=10 bottom:=15;
legendupdate update:=0 legend:=0 mode:=1;