LayerLayer-cmd
Performs various operations on existing layers. The layer command operates on the active layer, except where specified.
/Tip_icon.png) | Many of these features can now be handled with the laymanage X-Function.
|
Syntax:
layer [option] <width height xoffset Yoffset>
Options:
no option [width height xOffset yOffset]; Set layer position
Set layer width, height, and horizontal and vertical position on the page. Width, height, xOffset, and yOffset specify layer width, height, and horizontal and vertical position on the page (measured in the current units, from the top left corner of the page to the top left corner of the layer), respectively. A zero value for width or height retains the current setting. A single zero argument (layer 0) fits the active layer to the page. If no arguments are issued, the Select Columns for Plotting dialog box opens.
See the Example 3.
-3d; Control perspective of 3D plots
Syntax: layer -3d m value
Control of perspective, location of rotational axes, and plot relative to the layer frame (3D plots).
Perform the following options on a 3D graph for values of value:
P+1 = increase the perspective angle plus three units.
|
P-1 = decrease the perspective angle minus three units.
|
Rotation = reset the axes to their original rotational location.
|
Frame = fit the graph to the layer frame.
|
If value equals P+1, P-1, Rotation, or Frame, execute doc -uw to update the graph.
layer -3d m P+1; //Increase the perspective angle.
doc -uw; //Fresh the gragh.
layer -3d m rotation; //Go back to the original rotational location.
-3d r; set the 3D graph rotation
Syntax: layer -3d r %A deg ntimes delay
Set the 3D graph rotation. The ntimes and delay are only available for 3D openGL based graphs (Origin Version:9.0 SR0), they are used to create movie-like rotation effect.
%A could be X (X axis), Y (Y axis), Z (Z axis), V (Azimuth), H (Inclination), A (Roll) or R (Random change), which are the axis or direction to be rotated.
deg is the number of degrees +/- to rotate the graph.
ntimes indicates how many times the plot will be rotated and redrawn, if it's omitted, the plot will only rotate once without being redrawn.
delay is the delay time after each rotation in milliseconds.
After executing this command, execute doc -uw to update the graph.
layer -3d r X 90; //Rotate the X axis by 90 degree.
layer -3D r Z 15 24 500;//Rotate around Z axis by 15 degrees 24 times
//with a 500 millisecond delay at every rotation.
-3d c; convert GDI-based 3D graph to OpenGL based
Syntax: layer -3d c
Origin Version: 9.0 SR0
To convert the GDI-based 3D graph in the active graph layer to be OpenGL-based.
This is an example to make all GDI-based 3D graphs in an Origin project produced by earlier versions or when the system variable @ogl=1 is 0 convert to OpenGL based.
doc -e LP //execute for all graph windows
{
layer -3d c;//convert the current layer to OpenGL
}
-a; rescale the X and Y axes of the active layer to show all the data plotted in that layer
Syntax: layer -a
Rescale the X and Y axes of the active layer to show all the data plotted in that layer.The range of the X axis includes the rescale margin and begins and ends on the nearest major or minor tick. To rescale only the X or Y axis, set the other axis as fixed (for example, using layer.axis.rescale = 1 ). You can then save the graph window as a template.
Note:
Variations of the -a option are supported, and can be specified using the following scale identifiers:
x = x scale
y = y scale
z = z scale
m = color map
By combining one or more of these scale identifiers, you control which are rescaled on data change. Rescaling is applied to those which are NOT listed (e.g. layer -ayzm will trigger rescale of the x axis only; the y and z axes and color map are not rescaled).
|
-a ma; rescale the X and Y axes of all linked layers together to show all the data
Syntax: layer -a ma
Rescale the X and Y axes of all linked layers in one family together to show all the data. Note: layer -a is only used to rescale the current layer; layer -a ma is used to rescale all linked layers in current graph window.
-at; rescale the X and Y axes of the active layer, ignoring tick settings
Syntax: layer -at
Rescale the X and Y axes of the active layer to show all the data plotted in that layer, but ignore tick settings.The range of the X axis will be the data range plus the rescale margin.
-b; special plotting parameters
Syntax: layer -b parameter value [value2 value3]
Minimum Origin Version Required: 8.51 SR1
Special plotting parameters: exchange X/Y axes, stack plots, draw axes/grid lines on top of data, clip data, show frame, parallel plot. Flag the given parameter as on or off for the active layer or toggle its state. value2 and value3 are only available for the s parameter. The possible parameters are:
a = draw Axes on Top of Data. value1 = 1 draws Axes on Top of (after) Data; value1 = 0 draws Data after (on Top of) Axes; value1 = -1 toggles state.
|
b = draw the plot in Scroll mode (=1) or Sweep mode (=2). Also, see Plot -a command. See the sample in this topic to demonstrate these graph drawing modes. See Example-6 in this topic.
|
c = Clip Data to Frame. value1 = 1 turns on Clip Data to Frame; value1 = 0 turns it off. value1 = -1 toggles state.
|
f = Show the frame. value1 = 1 turns on the Layer Frame; value1 = 0 turns it off. value1 = -1 toggles state.
|
g = draw Grid on Top of Data. value1 = 1 show Grid lines in front of Data; value1 = 0 show Grid lines behind Data. value1 = -1 toggles state.
|
polar = Polar Plot Y axis Range. value1 of 0 fixes Y 'From' value at zero. value1 of 1 uses Y display range.
|
pp = switch between Line Series plot and Parallel plot. value of 0 will convert parallel plot to line series plot. value of 1 will covert line series plot to parallel plot.
Minimum Origin Version Required: 2018
|
pr = Polar Plot Orientation. value1 of 0 places 0 angle radius pointing right and angles increment Counter Clockwise. value1 of 1 places 0 angle pointing up and angles increment Clockwise.
|
s = stack data plots. When parameter is s, the value can be -2, 0, 1, 2, 3, and 4. For -2, enable stacking and the stack state is set to Individual by default. Set Gap Percent to value2 and Keep Proportion of Plot Range to value3 (can further set the Multiplier by set command if needed). For 0, set stack offset of plots to None. For 1, set stack offset of plots to Cumulative. For 2, set stack offset of plots to Constant of value2. For 3, set stack offset of plots to Auto, and Gap Percent to value2 (can be NANUM if need to skip) and Keep Proportion of Plot Range to value3. For 4, set stack offset of plots to Individual. value2 and value3 for X Individual and Y Individual respectively, can be 1 = on, or 0 = off.
Minimum Origin Version Required: 2016 SR0
|
x = exchange X and Y axes.
|
-b 3DB; set graph display caching
Syntax: layer -b 3DB value
Set graph display caching to none, raster, or vector.Value = 0 for no caching. Value = 1 for raster caching. Value = 2 for vector caching.
-b R; set worksheet as editable or read-only
Syntax: layer -b R value
Set worksheet as editable or read-only.Value = 0 for editing worksheet. Value = 1 for read-only worksheet.
-c; count datasets plotted in the active layer
Syntax: layer -c
Count datasets plotted in the active layer.Put the result into the count variable, and concatenate the names of all datasets into %Z string register.
-cam; control the directions of 3D OpenGL plot
Syntax: layer -cam -A value -I value -R value
Minimum Origin Version Required: 9.0 SR0
Set the Azimuth, Inclination and Roll values respectively. The setting can also be accessed by using the layer.camera object.
-cm l[r|p]; Load a saved color map
Syntax: layer -cm l[r|p] fileName [index|name]
Load a saved color map.The optional r switch converts a palette index to RGB values.The optional p switch converts RGB values to a palette index. If the layer contains multiple data plots, use index or name to specify a data plot other than the active data plot. The string notation %(index, @D) returns the name of the index'th data plot.
-cm s[r|p]; Save a color map
Syntax: layer -cm s[r|p] fileName [index|name]
Save a color map.The optional r switch converts a palette index to RGB values.The optional p switch converts RGB values to a palette index. If the layer contains multiple data plots, use index or name to specify a data plot other than the active data plot. The string notation %(index, @D) returns the name of the index'th data plot.
-cx; Change X Data
Syntax: layer -cx dataset plotIndex
Minimum Origin Version Required: 9.1 SR0
Change the plot's X data to the specified dataset.
-cxy; Change XY Data
Syntax: layer -cxy bookSheet plotIndex
Minimum Origin Version Required: 9.1 SR0
Change the plot's X and Y data to the datasets in the specified sheet.
-cy; Change Y Data
Syntax: layer -cy dataset plotIndex
Minimum Origin Version Required: 9.1 SR0
Change the plot's Y data to the specified dataset.
-d; delete the active layer
Syntax: layer -d
Delete the active layer, but keep data (in loose datasets).
This will delete the sheet and if last sheet deleted, the book will be deleted as well.
This command was expanded in <font, color="red"> (8.0SR2)</font> as follows:
layer -d name; // del layer/sheet in active page
layer -d [book]sheet;// general range notation
Also supported are the accompanying d, k, and u switches,
layer -dd; // del active layer, delete data too
layer -du; // del active layer, adding undo
layer -dk; // del active layer, keeping book if last sheet is deleted
layer -duk; // del active layer, with both 'u' and 'k' options
Notes:
- -duk and -dku are the same
- If u switch is used on non-active book, then it will first be activated before del, as only active book supports undo.
-dk; delete the active layer and undelete the book
Syntax: layer -dk
Delete the active layer. The book is kept undeleted.
This will delete the active layer from the active book and keep the book even if all sheets are deleted.
-e; remove a dataset from the active layer but keep the data plot style holder
Syntax: layer -e dataset
Remove a dataset from the active layer but do not remove the data plot style holder.You can also use this command option to remove multiple datasets from the layer. One way to do this is to list the datasets after the -e option. For example, the following command removes book1_b and book1_c from the layer:
layer -e book1_b book1_c;
You can also specify a string variable that holds the names of the datasets you want to remove.
The following script performs the same action as the previous example:
%Z = "book1_b book1_c";
layer -e %Z;
Furthermore, because the -c option puts the names of the datasets in the active layer into the %Z register, the following script removes all the datasets from the layer:
layer -c;
layer -e %Z;
-g; group all datasets in the active layer
Syntax: layer -g [BeginIndex EndIndex];
Minimum Origin Version Required: 8.6 SR1
Group datasets from BeginIndex to EndIndex. If no begin and end indexes are specified, it will group all datasets in the active layer.
-gu; ungroup all datasets in the active layer
Syntax: layer -gu [PlotIndex]
Minimum Origin Version Required: 8.6 SR1
Upgroup the grouped datasetss in the active layer.
-h; hide or show the layer
Syntax: layer -h value
Hide or Show the layer.If value = 1, hide the layer. If value = 0, show the layer. This command does not automatically refresh the window display.
-hp; hide or show data plot(s)
Syntax: layer -hp value PlotIndex
Minimum Origin Version Required: 8.6 SR0
Hide or Show the data plot(s) in the active layer. If value = 1, hide the data plot(s). If value = 0, show the data plot(s). PlotIndex is used to specify the index (start from one) of which data plot to hide or show. If PlotIndex is ignored, all data plots in the active layer will be hidden or shown.
-i; delete all data plot style holders in the active graph window layer
Syntax: layer -i
Delete all data plot style holders in the active graph window layer. Resave the graph window as a template to update the template settings.
-i; add a dataset to the active layer
Syntax: layer -i dataset
Add a dataset to the active layer.Include dataset in the active layer, that is, add dataset to the Layer Contents list in the Layer n dialog box. This is the standard method for plotting a dataset. If dataset is omitted, this command removes all the data plot style templates within the layer.You can also use this command option to add multiple datasets to the layer. One way to do this is to list the datasets after the -i option. For example, the following command adds book1_b and book1_c to the layer:
layer -i book1_b book1_c;
You can also specify a string variable that holds the names of the datasets you want to add. Thus, the following script performs the same action as the previous example:
%Z = "book1_b book1_c";
layer -i %Z;
Even you can specify a subrange for the dataset. The following script plots data in row 5 to 10 of column B.
range rr = col(B)[5:10];
win -t plot;
layer -i rr;
-i#; replot into the plot type specified by #
Syntax: layer -i# dataset
Replot into the plot type specified by #. Here, # is a number to indicate the plot type, and there is no SPACE between the -i and the number. The graph types and numbers are used as in Worksheet -p command. See the list of graph types and their numbers (IDs).
If dataset is omitted, this command removes all the data plot style templates within the layer.
-ic; Copy all data plots from the specified layer into the active graph layer
Syntax: layer -ic sourceGraph sourceLayerNumber
layer -ic graph2 2; //copy graph2 to layer2 of graph1
Copy all data plots from the specified layer number of the specified graph window into the active graph layer.
-ie; delete all data plot style holders that are not in use in the active graph window layer
Syntax: layer -ie
Delete all data plot style holders that are not in use in the active graph window layer. Resave the graph window as a template to update the template settings.
To find out which style holders are in use, use list o;. This command returns three attributes of the objects (including data plot style holders) in the active graph window
layer: index type* name.
Type = 7 indicates a data plot style holder. The asterisk(*) indicates the style holder is in use.
-il; add labels to an existing unlabeled dataplot (80SR5)
Syntax: layer -il dataSetName
Add label text to an existing unlabeled dataplot by specifying its name. By default, the y-value for each datapoint is used as the label text, and each datapoint is labeled. Custom label text cannot be specified with this option. Related switches are:
Switch
|
Action
|
ilr
|
Use row-index as label text
|
ilx
|
Use x-value as label text
|
ily
|
Same as -il
|
ilxy
|
Use (x,y) values as label text
|
-ip; add a dataset to the active layer even the dataset exists in the layer (90SR0)
Syntax: layer -ip dataset
This switch is similar to the -i switch, except that if the added dataset is already in the active layer, the -i switch will not add this dataset to the active layer anymore, but the -ip switch will still add it to the active layer. For example:
range aa = [mbook2]1!1;
range bb = [mbook2]1!2;
layer -ip aa bb;
-iu; delete all data plot style holders
Syntax: layer -iu
Delete all data plot style holders that are in use in the active graph window layer. Resave the graph window as a template to update the template settings. See the -ie option for more information.
-j; extract multiple data plots
Syntax: layer -j
Extract multiple data plots in a single layer into a multiple panel (layer) graph in which each data plot displays in its own layer.
-k; open the Plot Details or Layer n dialog box
Syntax: layer -k value
Open the Plot Details or Layer n dialog box, depending upon the value specified.If value = p, open the Plot Details dialog box for the active layer. If value = c, open the Layer n dialog box for the active layer. If value = d, open the Link Axes Scales tab of the Plot Details dialog box for the active layer. (Note: The active layer must be a linked layer to open this dialog box.)
-les; set editable cells on a protected worksheet
Syntax: layer -les value
When data protection is turned on in the worksheet(layer -lw 2), all the cells locked to editing. To edit specific cells on a protected worksheet, set the cell block as editable before protecting the worksheet.
Minimum Origin Version Required: 9.1 SR0
value
|
Action
|
0
|
Clear all editable cell blocks from active sheet.
|
1
|
Set the active, selected cell blocks to editable.
|
2
|
List the editable cell blocks in the active sheet.
|
Note: Layer -les 0 or Layer -les 1 fails when the worksheet has been protected. You need to set cell blocks as editable before protecting the sheet.
|
newbook;
worksheet -s 2 1 2 4; // Select row 1 to row 4 in column 2.
layer -les 1; // Set active selection of cell block to editable before turning on data protection.
layer -lw 2; // Turn on data protection in the active sheet.
layer -les 2; // List the editable cell blocks in the active sheet.
-lt; print the current protection bits
Syntax: layer -lt
Minimum Origin Version Required: 9.1 SR0
-lw; turn on protection on worksheet level
Syntax: layer -lw hex(hex value)
Minimum Origin Version Required: 9.1 SR0
Hex Value
|
Description
|
--
|
Turn on all protection bits
|
0
|
Remove all protections on the active worksheet.
|
2
|
Data Protection: This includes all cells in a worksheet (data cells and label cells).
|
80
|
Structure Protection: Keep the columns in the sheet unchanged. Prevent insert/delete of columns or moving of columns. However, allow rows to be changed.
|
100
|
Rename Protection: Prevent renaming of the sheet.
|
400
|
Delete Protection: Prevent the worksheet from being deleted.
|
Note: Multiple protection flags can be applied (values are additive).
newbook;
lay -lw hex(82); //Prevent editing data and modifying structure of the active sheet.
lay -lw hex(180); //Prevent modifying structure and renaming the active sheet.
|
-m; open the Layer Clipping Margins dialog box for the active layer
Syntax: layer -m
Open the Layer Clipping Margins dialog box for the active layer.
-n; add a nonlinked layer to the active graph window
Syntax: layer -n
Add a nonlinked layer to the active graph window displaying a bottom X and left Y axis.
-n Both; add a linked layer to the active graph window displaying a top X and right Y axis
Syntax: layer -n Both
Add a linked layer to the active graph window displaying a top X and right Y axis.
-n X; add a linked layer to the active graph window displaying a top X axis
Syntax: layer -n X
Add a linked layer to the active graph window displaying a top X axis.
-n Y; add a linked layer to the active graph window displaying a right Y axis
Syntax: layer -n Y
Add a linked layer to the active graph window displaying a right Y axis.
-o; execute (operate) the specified script for the specified layer
Syntax: layer -o layerNumber / layerName {script}
Execute (operate) the specified script for the specified layer.
// Paste the current time on layer 2 of graph1
layer -o [graph1]2 {label -s -t $(@D, D10)}
// Fill data to column B on specified sheet
newbook sheet:=3 result:=bn$;
layer -o [bn$]Sheet2 {
col(b)=data(1, 10);
};
-p; apply the X or Y scale of the active layer to all other layers in the active window
Syntax: layer -p axisScale
Apply the X or Y scale of the active layer to all other layers in the active window.
Set axisScale to X to apply the X scale, or to Y to apply the Y scale.
-r; reverse the order of the data plots in the active layer
Syntax: layer -r
Reverse the order of the data plots in the active layer.
-s; update Origin when you change sheet activity in an Excel workbook
Syntax: layer -s
Only for use with an Excel sheet embedded in Origin. Make the top Excel sheet the active layer in Origin. Execute layer -s after making a new Excel sheet active, or after adding a new sheet to the Excel workbook.
-s n; select the active layer in the active window
Syntax: layer -s n
Select the active layer in the active window. The integer n specifies the layer number. You can also set (and get) the active layer number using the page.active object property.
-se sheetName; Set the named Excel sheet as the active layer
Syntax: layer -se sheetName
Same as layer -s, but makes the named sheet (rather than the top sheet) active.
-t nrow; set the worksheet row that provides the axis title and the legend text for the dataplot
Syntax: layer -t [nrow]
Used with nrow, the -t option sets the worksheet row that provides the axis title and the legend text for the active dataplot. The X cell value provides the X axis title. The Y cell value provides the legend text.
Used by itself, the -t option clears the effect of the -t nrow option.
-tm; return merged cell range
Syntax: layer -tm nrow ncol bLabel
If cell at nrow and ncol is within a merged group of cells, the column and row range of the cells is returned (e.g. "cell merged range c1=1 c2=2 r1=4 r2=6").
-trv; switch the worksheet columns to column list view
Syntax: layer -trv value
Minimum Origin Version Required: 2018 SR0
Switch worksheet to column list view. 1 = true, 0 = false.
-u; change the units in which layer size and position are measured
Syntax: layer -u unit
Change the units in which layer size and position are measured.
Unit# specifies the type of units in the order listed on the Size/Speed tab of the layer's Plot Details dialog box. 1 = % of page, 2 = inch, 3 = centimeters, etc.
-us; update active Excel sheet and copy data
Syntax: layer -us
Similar to layer -s, but performs a full update of new Excel sheet information and data to Origin's hidden sheet. A full update means updating the sheet name, the number of columns, and the sheet data.
-usn; update active Excel sheet, do not copy data
Syntax: layer -usn
Same as layer -us, but does only a partial update; copies sheet information, but does not copy data.
-w; specify the beginning and ending column and row numbers
Syntax: layer -w wks [c1 r1 c2 r2] [graphType]
When no range is specified, plot the entire worksheet wks into the active layer.To select a worksheet range, specify the beginning and ending column and row numbers.If c1 and c2 = 0, plot all columns. If r1 and r2 = 0, plot all rows. The graphType value (graphType values can be found under the worksheet -p command) determines graph type: line, symbol, scatter, etc. If graphType = "?", the graph type that has been saved with the layer is used.
-x; get the layer frame dimensions into variables
Syntax: layer -x
Get the layer frame dimensions into variables v1 (width), v2 (height), v3 (left), and v4 (top).The values are in the current unit for the layer. To set the layer frame size, use the layer command without an option switch.
-Y ?; query the waterfall graph in the active graph window and assign the values of the X offset and Y offset to variables X and Y
Syntax: layer -Y ?
Query the waterfall graph in the active graph window and assign the values of the X offset and Y offset to variables X and Y.The X and Y offset amount is expressed as a percentage.
-Y !; Disable the X and Y offsets in the waterfall graph in the active graph window
Syntax: layer -Y !
Disable the X and Y offsets in the waterfall graph in the active graph window.
-Y; set the X and Y offset to produce a waterfall effect for all the data plotted in the layer
Syntax: layer -Y x, y
Set the X and Y offset to produce a waterfall effect for all the data plotted in the layer.The x and y offset amount is expressed as a percentage (you must include the comma between the x and y offset). Note: To assign these offset values to variables X and Y, execute the layer -y ? command after setting the offsets.
layer -y 5, 10;
layer -y ?;
-z; set zero angle and direction for polar plot
Syntax: layer -z angle, direction
Minimum Origin Version Required: 8.51 SR0
Set the zero angle and direction for polar plot. The angle is the zero angle to be used (i.e. the angle points at 3 o'clock direction), and if direction is 1, clockwise is used, if direction is 0, counter-clockwise is used.
Examples:
Example 1
The following script changes the units to pixels.
lay -u 5;
Example 2
The next script exchanges the X and Y axes.
lay -b x 1;
Example 3
The next script sets xOffset and yOffset to 45. It retains the current values for width and height.
lay 0 0 45 45;
Example 4
Given three layers, the following script sizes each layer to 20% of the page width and 80% of the page height. It arranges the layers 10% from the top of the page, starting at 8% in from the left, and separated by 12% of the full page.
width = 20;
height = 80;
for (ii = 1; ii <= 3; ii++)
{
layer -s ii;
layer width height (8+(ii-1)*(width+12)) 10;
};
Example 5
The following script creates a new graph window, adds data to the layer, and then creates a second graph window and adds data to that layer.
%A = data1; //assign worksheet name to %A
loop (ii, 2, 3)
{
win -t plot line; //open graph from line template
%B = data1!wks.col$(ii).name$; //assign column name to %B
layer -i %A_%B; //add data to layer
layer -a; //rescale axes to show all data
}
Example 6
The following script demonstrates the plotting animation in both Scroll and Sweep modes specified by Layer -b b command:
// BEGIN DEMO FOR SCROLL AND SWEEP MODES
// New project
doc -s;
doc -n;
// Add XYXY columns
wo -a 4;
wo -t 3 4;
wo -t 5 4;
// Remember book name
%Z = %H;
// Open a plot window
win -t plot;
// Include three XY pairs (Red, Green & Blue)
layer -i %Z_B;
set %Z_B -c 2;
layer -i %Z_D;
set %Z_D -c 3;
layer -i %Z_F;
set %Z_F -c 4;
// Setup the scale
x1 = 0;
x2 = 50;
y1 = -2.5;
y2 = 12.5;
delay = 0.03;
type -b Demonstrate Scroll mode;
layer -b b 1; // Set layer to Scroll model
j=1;
k=1;
l=1;
angle = 0;
repeat 200 {
plot -a %Z 1 $(j) $(sin(pi*angle/180));
j+=1;
plot -a %Z 3 $(k) $(2+2*cos(4*pi*angle/180));
k+=1;
plot -a %Z 5 $(l) $(8-2*sin(pi*angle/180)-2*cos(3*pi*angle/180));
l+=1;
second -p delay;
angle += 5;
};
type -b Now demonstrate Sweep mode;
angle = 0;
layer -b b 2; //Set layer to Sweep mode
repeat 200 {
plot -a %Z 1 $(j) $(sin(pi*angle/180));
j+=1;
plot -a %Z 3 $(k) $(2+2*cos(4*pi*angle/180));
k+=1;
plot -a %Z 5 $(l) $(8-2*sin(pi*angle/180)-2*cos(3*pi*angle/180));
l+=1;
second -p delay;
angle += 5;
};
type -b End of demonstration;
// END DEMO
See Also:
Layer
Layer.Axis,
Layer.Axis.Break,
Layer.Axis.Grid,
Layer.Axis.Label,
Layer.Cmap (object),
Layer.Plotn.BoxChart
|