Layer

LabTalk Object Type:

Window


Note: A layer in Origin can be either a graph layer or a worksheet or matrixsheet (i.e. each worksheet/matrixsheet in a workbook/matrix is a layer). Most layer properties apply to a graph layer, but some apply to worksheets and matrix sheets. The wks object is the layer analogue for worksheets and matrixsheets.

The layer object controls the appearance of the specified (or active) layer. The layer object for a graph contains the axis sub-object. The axis object also contains sub-objects. You can either use the layer.property notation to access the active layer's properties, or use the range notation to define a layer range:

range layerObject = [winName]layerIndex!

For example:

// Use layer object to access active layer properties ...
layer.tickl = layer.tickl * 2; // Double the tick length
// or specify the layer (which need not be active) in the active graph ...
layer3.color = color(cyan); // Set layer3 background color to cyan
// or refer to layer in another window ...
// Set width of layer 2 in 'Graph2' to 50 (current units)
Graph2!layer2.width = 50; 
// Define two range variables ...
range layA = [Graph1]1!, layB = [Graph2]1!; 
layB.width = layA.width; // Make width of 'B' layer same as 'A'

Properties:

winName!layer#.property =

The winName! parameter is optional. If winName! is not specified, a layer in the active window is affected.

# is the layer number. If # is not specified, the active layer is used.

Property Applies Access Description
layer.3DCoor graphs Read/write,
numeric
Coordinate system: 1 = right-hand system, 0 = left-hand system.
layer.BiAxy

(2023b)

graphs Read/write,
numeric
Whether to rescale graph XY coordinates when the coordinates of the background image changes. Available only when the graph layer has an background image: 0 = Turn off Auto-Rescale-Background-Image feature, 1 = Turn on Auto-Rescale-Background-Image feature.
layer.bixy$

(2022)

graphs Read/write,
string
Apply layer XY coordinates to the image inserted into graph layer as background for project created in Origin 2021b and previous.
  • layer.bixy$="update"; to update the coordinates of background image with unit to that of graph layer.
  • layer.bixy$=; to return the image coordinates
layer.border graphs Read/write,
numeric
Layer border pattern: 0 = off, 1 = shadow, 2 = marble, 3 = white out, 4 = black out.
layer.bridgechart.enable graphs Read/write,
numeric
Enable Bridge Chart data plotting behavior. 0 = disable; 1 = enable.
layer.bridgechart.connectline graphs Read/write,
numeric
Show Connect Line between columns. 0 = disable; 1 = enable. Line can be customized using the draw command.
layer.bridgechart.connectbysubset

(2018 SR0)

graphs Read/write,
numeric
When connectline = 1, enable or disable Connect by Subset. 0 = disable; 1 = enable. When enabled, lines are drawn to connect subsets.
layer.bridgechart.subtotal$ graphs Read/write,
numeric
Space-delimited set of data indices for totals/sub-totals (e.g. layer.bridgechart.subtotal$="1 3 5 7")
layer.bridgechart.cumulative graphs Read/write,
numeric
When enabled, only total/subtotal data points will be cumulatively stacked. 0 = disable; 1 = enable.
layer.camera.azimuth 3D OpenGL based graphs Read/Write,
numeric
Set the Azimuth of the 3D plot, refer to layer -cam command. Requires a window refresh when writing. ( e.g. doc -uw; )
layer.camera.inclination 3D OpenGL based graphs Read/Write,
numeric
Set the Inclination of the 3D plot. Requires a window refresh when writing.
layer.camera.roll 3D OpenGL based graphs Read/Write,
numeric
Set the Roll of the 3D plot. Requires a window refresh when writing.
layer.cindex graphs,
worksheets,
matrices
Read only,
numeric
The zero-basic creation index of a layer for its own page. Note: The layer number can be gotten by the page.findLayer(cIndex) method with the specified creation index.
layer.clip graphs Read/write,
numeric
Graph layer's Clip Data to Frame option. For 2D graph, 0 = off, 1 = Clip to frame, 2 = Hide if outside frame. For 3D graph, 0 = disable, 1 = enable.
layer.clip.x1/x2/y1/y2/z1/z2 graphs Read/write,
numeric
Get/Set the X/Y/Z dimension of data display range if 3D Graph layer's Clipping is enable
layer.color graphs,
worksheets,
matrices
Read/write,
numeric
For graph, it's layer's background color; and for worksheet/matrix it's tab color. Numbers from the color list, or transparent (0). The color() function can be used, as in: layer.color = color(blue);

Prior to 8.0, worksheet color referred to row/column header. It no longer applies.

layer.comments$ graphs,
worksheet,
matrices
Read/write,
string
Comments for a layer. Note: For a Worksheet, comments appear as a tooltip for the worksheet name and may be edited from a context menu. For a graph layer, the comments can only be accessed in LabTalk.
layer.commonrange

(2020b)

graphs Read/write,
string
Establish a common display range for all plots in the layer. 0=(default) no common display; 1 = common display range.
layer.coortype graphs,
worksheets
Read,
numeric
0=cartesian, 1=polar, 2=ternary, 3=smith chart, 16=3D
layer.displayname$ worksheets,
matrixsheets,
graphs
Read Only,
string
It is obsolete for workbook since Origin 2020b. Use layer.name$ instead.
Returns the layer display name according to layer.namemode. Since graphs never show layer long names, this property can return a string which cannot be seen in the GUI.
layer.exchangexy graphs Read/write,
numeric
Only for Cartesian coordinates. Whether to flip XY axes; 1 = true, 0 = false.
layer.factor graphs Read/write,
numeric
Set scaling factor as on the Display tab of the layer's Plot Details dialog box. When layer.fixed is 0, layer.factor will update when user resizes the layer.
layer.fixed graphs Read/write,
numeric
Scale (Elements) With Layer Frame : 1 = unchecked, 0 = checked. See the Display tab of the layer's Plot Details dialog box.
layer.groupn.allCols graphs Read/write,
numeric
Plot all Y columns that are included in the plot group groupn, in the source worksheet. The group is comprised of a single X column, plus any and all Y columns to the right of that X column. This allows the user to add or remove columns of Y data in the source worksheet and have the graph update dynamically: 1 = update graph dynamically, 0 = do not update.
//auto update plots in group1 
//when add/remove datasets in source sheet
layer.group1.allCols=1
layer.height graphs Read/write,
numeric
Height of the layer frame, measured in units specified by layer.unit.
layer.include.group graphs,
worksheets
Read/write,
numeric
Used when the layer.include() method is operating on a vector. 1 = group and 0 = ungroup.
layer.HideOthers

(2020)

graphs Read/write,
numeric
Show the active layer only, hide other layers: 1 = Hide other layers and 0 = Show all layers
layer.include.useAll graphs,
worksheets
Read/write,
numeric
Used when adding datasets with the layer.include() method in a box chart. 1 = disregard column designations, 0 = use column designations.
layer.info graphs,
worksheets,
matrixsheets
Read/write,
tree
Layer storage object. Typically contains metadata associated with imported file. To access the data of User Tree, please use layer.info.tree.
tree tr = layer.info.tree$; //get
tr.=;
layer.info.tree$ = tr$; //set
layer.is3D graphs Read only,
numeric
Returns 1 if the layer is from a 3D plot type (3D charts, 3D surfaces, and 3D wire frames). Otherwise, returns 0.
layer.is3DGL graphs Read only,
numeric
Returns 1 if current 3D plot is based on 3D OpenGL. Otherwise, returns 0 for GDI based graph supported in version earlier than Origin 9.0.
layer.isisometric graphs Read/write,
numeric
Link Axis Length to Scale with X:Y Ratio (isometric) for 2D graphs: 1 = Link axis length to scale, 0 = Do not link axis length to scale. See the Size tab of the layer's Plot Details dialog box.
layer.left graphs Read/write, numeric Distance from the frame to the left edge of the page. Measured in units specified by layer.unit.
layer.link graphs Read/Write,
numeric
Linked To layer number, 0 if no link.
layer.light graphs Read/Write,
numeric
The following properties exist to control lighting in 3D openGL plots:
Property Description
.mode Lighting Mode: 0 = None, 1 = Directional.
.direction.h Direction, Horizontal: the direction of light source in the horizontal plane 0 to 359.
.direction.v Direction, Vertical: the direction for light source in the vertical plane: -90 to 90.
.direction.dynamic Dynamic Light Source: 0 = enable, 1 = disable.
.ambient Light Color, Ambient: color is a number from the LabTalk List of Colors.
Alternately, use the LT color() function to specify a color.
.diffuse Light Color, Diffuse: color is a number from the LabTalk List of Colors.
Alternately, use the LT color() function to specify a color.
.specular Light Color, Specular: color is a number from the LabTalk List of Colors.
Alternately, use the LT color() function to specify a color.
.ka Ambient Intensity: not used.
.kd Diffuse Intensity: value from 0 to 100.
.ks Specular Intensity: value from 0 to 100.
.shininess Shininess: value from 0 to 100.

Note that user-interface controls for these settings are found in two places:

layer.longname$ worksheets,
matrixsheets,
graphs
Read/Write,
string

Long Name for a layer. Beginning with Origin 2020b, worksheet/matrixsheet "Long Name" becomes "Label". longname can hold up to 518 characters. In versions prior to Origin 2020, display of Long Name on the sheet tab was controlled by layer.namemode. However, beginning with Origin 2020, layer.namemode will only apply when system variable @SSL = 0.

Graph layers have no option to show Long Name although the property can be read and written.

layer.matmaxptsenabled graphs Read/Write,
numeric
Enable/Disable speed mode for graphs from matrix.

See also:
layer.matmaxrows
layer.matmaxcols

layer.matmaxcols graphs Read/Write,
numeric
Maximum columns to show when speed mode is on. This value should greater than or equal to 2.

See also:
layer.matmaxptsenabled

layer.matmaxrows graphs Read/Write,
numeric
Maximum rows to show when speed mode is on. This value should greater than or equal to 2.

See also:
layer.matmaxptsenabled

layer.maxpts graphs Read/write,
numeric
Speed mode for worksheet data plots. Maximum number of data points to display for each column based data plot, for screen display only. Printing and export will not use speed mode (unless requested). To turn off speed mode for worksheet data plots, set this to 0.
layer.name$ graphs,
worksheets,
matrixsheets
Read/write,
string
The Short Name of the active layer. Beginning with Origin 2020b, worksheet/matrixsheet "Short Name" becomes "Name". Prior to Origin 2020, you used layer.namemode to control whether to show Short Name or Long Name on the sheet tab. Since Origin 2020, tab name display is controlled by system variable @SSL.
layer.namemode worksheets,
matrixsheets
Read/write,
numeric
Determines how sheet name should display. 0 = Show Long Name if available, 1 = Short Name(default), 2 = Long Name. Note that with Origin 2020, this property became obsolete, having been replaced by system variable @SSL.
layer.orientation graphs Read/write,
numeric
For printing

0 = auto, which means follow current printer
1 = portrait
2 = landscape

layer.plot worksheets,
matrixsheets
Read/write,
numeric
Active data plot number in the layer.
layer.rescalego graphs Read/write,
numeric
enable graph rescale to consider graph object attached to layer and scale

0 = disable
1 = consider graph object attached to layer and scale
2 = to include annotations bits can be combined

layer.ResizeParent graphs Read/write,
numeric
Specify whether the parent layer will follow the moving/resizing of current linked child layer. 0 = not follow, and 1 = follow.
layer.s

(2020)

graphs Read/write,
numeric
Edit the property of the selected axis in the layer. For example, you can use the following scripts to rescale bottom X axis range if it has been selected.
layer.S.From = 5;
layer.S.To = 10;
layer.sauto graphs Read/write,
numeric
Auto Rescale control:

0 = no auto rescale
1 = auto rescale XY
2 = auto rescale XYZ(xyz if surface, xycolormap if contour

layer.show graphs,
worksheets,
matrices
Read/write,
numeric
Show or hide the layer: 1 = show, 0 = hide.
layer.showData graphs Read/write,
numeric
Display of data plots: 1 = show, 0 = hide.
layer.showLabel graphs,
worksheets
Read/write,
numeric
Display of text and graphic objects: 1 = show, 0 = hide. Unlike objects hidden with the Visible check box in the Label Control dialog box, all labels remain selectable.
layer.skewangleb graphs Read/write,
numeric
Internal angle between X and Y axes. Need to run layer -PGM 1 to enable axis skew first.
layer.skewanglex graphs Read/write,
numeric
Positive values rotate X axis in counter-clockwise direction. Need to run layer -PGM 1 to enable axis skew first.
layer.showx
layer.showy
graphs Read/write,
numeric
Display of X or Y axis: 1 = show, 0 = hide.
layer.tickL graphs Read/write, numeric Tick length in units of 0.1 pt. When you set this property, it sets the tick length for all the ticks in the layer. When you read this property, it returns the tick length for the first displayed X axis in the layer.
layer.tickW graphs Read/write,
numeric
Tick thickness. See layer.tickL for read and set conventions.
layer.title graphs Read/write,
numeric
show/hide layer title.
layer.top graphs Read/write,
numeric
Distance from the frame to the top edge of the page. Measured in units specified by layer.unit.
layer.tpx

(2021b)

graphs Read/write,
numeric
Specify how to decide the table edge for the axis table row when you have set Major Tick Type as By Custom Positions with a column; or when using some date-time Formats with axis (tick) tables.

When layer.tpx=1, use the center of custom ticks as table edge.
When layer.tpx=0, use the custom tick position as table edge. By default, layer.tpx=0.

layer.unit graphs Read/write,
numeric
Layer frame measurement units: 1 = % page, 2 = inches, 3 = cm, 4 = mm, 5 = pixel, 6 = points, and 7 = % of linked layer.
layer.width graphs Read/write,
numeric
Width of the layer frame, measured in units specified by layer.unit.

Methods:

Method Description
layer.include(Dataset [,PlotType]) Dataset is the name of the dataset to be added to the active graph layer. PlotType (optional) is the Plot Type ID for the desired graph.
layer.plot.copy() Copy the active plot or active plot group, to the Clipboard.
layer.ROI(append,type,width,optn) <p align="right">(2022)

Add/Romove ROI box to layer.
  • append determines whether to add or remove ROI. Option list:
0 Clean existed ROI(s) on the layer and add a new ROI.
-1 Delete all ROI(s) in the layer.
1 Append a new ROI to the layer.
  • type determines the shape of ROI box. Option list:
0 Rectangle ROI
1 Horizontal span across layer
2 Vertical span across layer
  • width specifies the width of ROI box. defaul "0" means ignoring the width.
  • optn determines the ROI is resizable or not: 1 = disable resizing, 0 = enable resizing

For example,

layer.ROI(); //add a ROI of default settings in the middle of the layer
layer.ROI(-1); //delete all ROIs in the layer

//append a span-layer vertical ROI with 3 pixel in width and disable resizing
layer.ROI(1,2,3,1);
layer.setstr(name,text)

(2022)

If import multiple image files into one image window, use layer.setstr and layer.getstr to set and get specified layer name. Use layer.setstr to set name of name layer frame as text.
layer.getstr(name,StringReg)

(2022)

If import multiple image files into one image window, use layer.setstr and layer.getstr to set and get specified layer name. Use layer.getstr to get name of name layer frame and save it to a% String Register.

For example,

//save name of layer ''myocyte1'' to %A
layer.getstr(myocyte1,A);
layer.addImg(imagename, 8)

(2022b)

Insert image from Image window imagename to graph layer, at the XY coordinates of the image scale.
layer.plane.add(Type, Postion, Color(optional))

(2023b)

Add multiple planes on the selected direction in a 3D graph.

Type determines the direction of the additinal plane. Option list:

  • 1= XY
  • 2= YZ
  • 3= ZX

Position determines the position of the additional plane. It is the axis position on the vertical axis of the additional plane.
Color is optional. It is the index value of Origin's default color list.
For Example,

layer.plane.add(1,100,3); //Add a XY plane at Z=100 with green color.