3.9.13 Text Label Substitution
When making graphs of worksheet or matrix data, most auto-generated labels -- including axis titles and graph legends -- are created by assigning plot metadata to a named label object. Each of these named label objects is saved in the graph template as an "empty", predefined string of characters which map to various bits of plot metadata. We refer to the run-time assignment of plot metadata to these labels as "substitution" and the syntax used to construct the "empty" strings as "substitution notation."
This page covers named label objects -- legends, axis titles and user-added labels created with the Text tool or by script (e.g.
label -sl). For information on plot data labels, see Notations and syntax used in labeling plotted data.
Text Label Names
Text labels on a graph, worksheet or matrix page typically have an object name that is exposed in the GUI or by script (axis tick labels are an exception). These labels or "objects" have a name that can be identified by opening the object's Properties dialog:
- Select a text object by clicking on it with your mouse, then right-click, and select Properties.
- In the Text Object dialog box, click on the Programming tab and look to the Name field.
As previously mentioned, LabTalk supports inserting metadata (project, page and dataset information) into your text labels using substitution notation. You can return or define which bits of metadata are used by a named label object, using objectName.text$.
For example in a graph legend, you might use...
legend.text$=\l(1) %(1,@LG) \l(2) %(2,@LG) \l(3) %(3,@LG);
to specify that for the each of three Y plots in the layer, use the Long Name, if available, plus Units to create the legend object.
Alternately, you could use the legendupdate X-Function to create the same legend, using the same @LG option:
legendupdate mode:=custom custom:=@LG;
Also, see this page on Legend Substitution Notation.
Besides legend other text object names on a graph include yl (left-side y-axis), xb (bottom x-axis), so that
yl.text$ = %(?Y,@WL); // Left Y axis title = the workbook Long Name of plotted Y
xb.text$ = %(1X,@LU); // Bottom X axis title = the units of the 1st plot's X dataset
yl.text$ = %(?Y,@(@LL<@LU>)); //Left Y axis title = the workbook Long Name of plotted Y followed by Units enclosed in < >.
The %(?Y) is a variable syntax that causes the axis title to default to a pre-specified data plot index (set in Plot Details: Legends/Titles: Data Plot Index for Auto Axis Titles), instead of an index (1, 2, ... n) that you supply.
User-created Text Objects
The following examples demonstrate substitution of data and metadata in user labels created by various methods:
Example 1: Use Text tool to create a label named "text" added and linked to display a value in a column label "User-parameter" row named named "No. of points":
text.text$="Number of points: %([S15-125-03.dat]Trial Run 1,@LD"No. of points",2)"
Example 2: Add a label named "filedate" via script that displays a formatted import file date for metadata associated with the worksheet or graph:
label -sl -n filedate "File Date: $("%(Book2, @W,SYSTEM.IMPORT.filedate$)",D0)";
Example 3: Numbers in a worksheet often display at lower precision than the internally-stored cell value. Add a label named "celldigits" that displays the worksheet value at the displayed precision:
label -sl -n celldigits "Col(Signal) displayed value is %([Book2]Sheet3, @WL, Signal, W)";
Add a label named "fullprecision" that displays the internally-stored, full precision cell value:
label -sl -n fullprecision "Col(Signal) full precision value is %([Book2]Sheet3, @WL, Signal)";
For more information on formatting substituted numeric values, see Return value in current column format with "W" and "@WL".
These syntaxes can be used for different applications. In some cases, you can combine and adapt notations as shown in the last example under User-created Text Objects, above.
| %(PlotIndex[PlotDesignChar], @option)
- Refer to a data plot by PlotIndex and a column from this plot by PlotDesignChar such as X, Y or Z. This syntax is used for legends and axis titles.
- Variable "@ options" and examples are listed under List of @ Options, below.
| %([workbookName]sheetName, @WL, column[row], W)
| %([workbookName]worksheetName, @option, columnNumber)
| %([workbookName]worksheetName!columnName,@option, varOrNodeName)
To combine multiple @options interspersed with arbitrary text, use the following syntax:
%(1,@(@LL(@LU)))// shown as '''Long Name(Units)'''
Complete List of @Options
Below is a table of available @ text-label options for customizing the text labels, including legend text and axis title. See the screenshots for the worksheet properties which will be referenced by the sample expressions:
|Note: While many of these "@" label options can only apply to workbook data, some of them are applicable to matrix data. For instance, the expression ...
... will return the matrixbook short name.
||Substitute Text From...
|| Column Short Name. Equivalent to @LS.
|| %(1,@C) --> B
|| Dataset name
|| %(?Y,@D) --> Book1_B
|| Group Name of current plot in a graph
|| %(2, @GG)
- Show the group name of current plot. The default group name g# will show as blank.
|| Layer Name of current plot in a graph
|| %(2, @GL)
- Show the layer name of current plot. The default layer name Layer# will show as blank.
|| Column Long Name, will return to missing value if long name does not exist. Equivalent to @LL.
|| %(1Y,@L) --> Delta Temperature
|| The nth X value
|| %(1,@L,2) --> 0.02
|| Long Name, if available, else Short Name.
|| %(1,@LA) --> Delta Temperature
|| Comments, if available, else Long Name, otherwise Short Name
|| %(1,@LC) -->|
|| The nth line of the Comments label row cell. Note that n is optional and that @LC1 = @LC.
|| %(1,@LC2) -->milled
|| The nth user-defined parameter. Note that n is optional and that @LD1 = @LD.
|| %(1,@LD2) -->235
|| The user-defined parameter of specified name.
|| The filter condition of the data plot. When there are multiple conditions, optional n = the nth line of filter condition (list order shown in Filter label row cell). Also, see LabTalk system variable @SFD
|| Make = %(1,@LF)-->Buick
|| Long Name (if not available then Short Name) and Units (if present). Equivalent to @U.
|| %(1,@LG) -->Delta Temperature (K)
|| The name of the first User-Defined Parameter.
|| %(1,@LH) -->UserDefined
|| The nth User-Defined Parameter. Note that n is optional and that @LH1 = @LH.
||Equivalent to @L.
|| %(1,@LL) --> Delta Temperature
|| 1st line of Comment, if available, else Long Name, otherwise Short Name.
|| %(1,@LM) --> YBCO
|| 1st line of Comments (if not available then Long Name, otherwise Short Name) and Units. Equivalent to @(@LM(@LU)).
|| %(1,@LN) --> YBCO(K)
|| The first System Parameter.
|| %(1,@LP) --> Version 2.1
|| The nth System Parameter. Note that n is optional and that @LP1 = @LP.
|| %(1,@LP2) --> 12/15/2004
|| The first User-Defined Parameter and Units (if available).
|| %(1,@LQ) --> S21(K)
|| The nth User-Defined Parameter and Units (if available). Differs from @LH by including Units. Note that n is optional and that @LQ1 = @LQ.
||%(1,@LQ2) --> 235(K)
|| The User-Defined Parameter (specified by name) and Units (if available).
||%(1,@LQ"RunNo") --> 07(K)
|| Column Short Name, equivalent to @C
|| %(1,@LS) --> B
|| %(1,@LU) --> K
|| Dataset range
|| %(1,@R) -->
[Book1]"Trial Run 2"!Col("Delta Temperature")[1:32]
|| Dataset range without row index
|| %(1,@R1) -->
[Book1]"Trial Run 2"!Col("Delta Temperature")
|| Starting row index of the plotted data
|| %(1,@RB) -->
|| Ending row index of the plotted data, same as @RN if @RB is 1
|| %(1,@RE) -->
|| Total number of rows in the plotted data (will not exclude missing values or masked data points)
|| %(1,@RN) -->
|| Long Name (if not available then Short Name) and Units (if present). Equivalent to @LG
|| %(1,@U) -->Delta Temperature (K)
| @V, n
|| The value of the nth point in the data plot.
|| %(1Y, @V, 2) -->0.02863
|| Use in Fill Area Under Curve graph only. When Fill to next data plot - Above Below Color is selected, this notation is used for labels to indicate the filled-color above / below base curve.
|| Short Name of book
| %(1,@W) -->Book1
|| The nth line of the WorkBook Comment. If optional n is not specified, only the first line will be shown.
<Origin EXE Folder>\Samples\Curve Fitting
|| Long Name of book
| %(1,@WL) -->S21-235-07
|| The nth line of the WorkSheet Comment. If optional n is not specified, only the first line will be shown.
||%(1,@WM) -->Data imported from
|| Project Explorer (PE) path of the book
| %(1,@WP) -->/Folder1/
|| Name of the sheet (workbook, matrix)
|| %(1,@WS) -->Trial Run 2
| @WT, ColIndex/ColName, RowIndex
|| The sheet cell value specified by the column index (or short name) and row index.
- %(1, @WT, 2, 3)
- the cell value at column 2, row 3 in the source sheet (worksheet, matrix) of the 1st data plot. Because it's numeric, you can use $($(%(1, @WT, 2, 3), .2)*100) to get string of the number with two decimal place times 100.
- %(1, @WT, B, 3)
- the cell value at column B, row 3 in the source worksheet of the 1st data plot.
| @WT, ColIndex/ColName, ColLabelRowCharacter
|| The worksheet cell value specified by the column index (or short name) and column label row character.
- %(1, @WT, B, C)
- Similar to B[C]$, this will get the Comment from column B, in the source worksheet of the 1st data plot.
Note: When units are displayed in the substituted texts, the English and Japanese versions of Origin enclose the units in parentheses (), while the
German version will use square-brackets .