# 3.9.7 Legend Substitution Notation

## Legend for Most 2D and 3D Graphs

For most 2D and 3D graphs, the legend is constructed using the following substitution syntax:

Plot Symbol Component: \L([LayerIndex.]PlotIndex[,PointIndex[,option]])
Text Component: %(LayerIndex.PlotIndex[XYZ, @option])

Note that the symbol component is enclosed by \L() and the text components is enclosed by %()

### Plot Symbol Component

• \L([LayerIndex.]PlotIndex[,PointIndex[,PlotElement]])
• \L([LayerIndex.]PlotIndex[,PointIndex][,Size:SizeOption])
• \L([LayerIndex.]PlotIndex[,PointIndex][,Style:StyleOption])
• \L([LayerIndex.]PlotIndex[,PointIndex][,LineWidth:WidthOption])
• \L([LayerIndex.]PlotIndex[,PointIndex][,Height:HeightOption])
• \L([LayerIndex.]PlotIndex[,PointIndex][,Width:WidthOption])
• \L([LayerIndex.]PlotIndex[,PointIndex][,Length:LengthOption])

This notation is used to construct the legend's data plot symbol, by displaying the symbol of the specified data plot from the specified layer.

1. LayerIndex(optional): The layer of the specified data plot, indexed from 1. For the active layer, this option can be omitted, as in \L(PlotIndex).
2. PlotIndex: The data plot's position (indexed from 1) in the data list at the bottom of the Data menu or in Layer Contents. Note: this list is for all plots in the active graph layer.
3. PointIndex(optional): If a particular point in a dataplot has been customized, this option is useful in displaying that particular point.
4. PlotElement (optional): 1=Show Border or Edge color as a block, 2=Show Interior color as a block, 3=Show Pattern Color (or Black) as a block, 4=Show empty Symbol (or special Not Used), 5=Not Used, 6=Not Used, 7=Show actual style.
5. SizeOption (optional): Size:## displays a scatter symbol at specific point size or Size:p## percentage of plot symbol size (can be > 100%).
6. StyleOption (optional): Style:### displays a sequence of symbols and/or line segments, where s=symbol, l=line segment. Can be listed in any order (e.g. "Style:sls" displays as symbol/line segment/symbol).
7. WidthOption (optional): LineWidth:p## displays line width as percentage of plot line size (can be > 100%).
8. HeightOption (optional): Height:p## displays block height as percentage of active dataset indicator (max value = 100%).
9. WidthOption (optional): Width:p## displays block width as percentage of active dataset indicator] (max value = 100%).
10. LengthOption (optional): Length:p## displays line length as percentage of width of active dataset indicator.

### Examples

Legend Entry Description
Legend of Specific Plot/Symbol
\l(1) %(1)

\l(2) %(2)

Both lines are the legends for the data plots in the active layer. The first line is for the first plot, and the second line for the second plot.

Based on the typical default specified in the Legends/Titles tab in the Plot Details dialog of the graph, the legend's label will look for Comments in the source data worksheet, if no Comments then Long Name will be used, and if no Long Name, Short Name is used.

\l(1.1) %(1.1)

\l(2.1) %(2.1)

The first line is the legend for the first plot in the first layer, and the second line for the first plot in the second layer.
\l(1) %(1, @LD1)

\l(1) %(1Y, @LD1)

The legend symbol is from the first plot in the active layer, and the legend's label is from the first User Parameter row of the Y column in the source data worksheet. Identical for 2D plots since Y is optional.
\l(1) %(1X, @L) The legend symbol is from the first plot in the active layer, and the legend's label is from the Long Name of the X column in the source data worksheet.
\l(2.3,5) %(2.3X, @LU) Lowest Value The legend symbol is from the fifth point in third plot in the second layer, and the legend's label is from the Units of the X column in the source data worksheet plus additional user-supplied text: Lowest Value.
\l(1,3,2) %(1) The legend symbol is from the 3rd symbol in the active layer, and the plot element used is the interior color.

Legend Entry Description Example
Legend of Partial Property of Symbol
\l(1) ) %(1) Original line+symbol plot
\l(1, style:s) ) %(1) Show symbol only for a line + symbol plot
\l(1,style:l) %(1) Show line only for a line + symbol plot
\l(1,style:sls) Show legend as symbol - line- symbol for a line + symbol plot

Legend Entry Description Example
Legend of Scaled Symbols
\l(1) ) %(1) Original line+symbol plot
\l(1,size:5) %(1) Show symbol size 5
\l(1,size:p150) %(1) Scale symbol size as 150% of original symbol size
\l(1, LineWidth:3) %(1) Show line width as 3
\l(1, LineWidth:p1000) %(1) Show line width as 1000% of original line width
\l(1, Length:p50 %(1) Show line length as 50% of original length
\l(1) ) %(1) Original column plot
\l(1, PatternHeight:p50) %(1) Show bar height as 50% of original height
\l(1, PatternWidth:p50) %(1) Show bar width as 50% of original width

Legend Entry Description Example
Legend of Plot Elements
\l(1) Bar Original bar plot (1st bar of 1st layer)
\l(1,1,1) Border Show border color of the 1st bar of 1st layer in a block
\l(1,1,2) Fill Show fill color of the 1st bar of 1st layer in a block
\l(1,1,3) Pattern Show pattern color of the 1st bar of 1st layer in a block

Notes:

Any text object can contain this syntax and act like a legend provided the Substitution Level in Programming Control is set to 1.

The active layer for any legend object is the layer to which the object is attached.

Only one object named legend can exist in any one layer.

## Enhanced Legend Formatting for Categorical Data

Categorical data is text which has been mapped to a value to allow for plotting and analysis. Each category value is assigned an index starting with one. You may refer to the plot requirement to construct legend for categorical values for details.

For categorical data Origin employs a special syntax to control what symbols and text are displayed in the legend. The syntax is similar to the default legend but includes a literal m in the second argument:

\L(PlotIndex[.DataPoint], mCategoryIndex, PlotElement) %(PlotIndex, mCategoryIndex, PlotElement)

### Arguments:

• PlotIndex: An integer which defines the data plot number.
• DataPoint: An integer indicating data plot point.
• CategoryIndex: The index number for a particular categorical entry.
• PlotElement: An integer which defines what plot element is displayed. The parameter can take values of 1 to 6, where 1=edge color, 2=fill color, 3=pattern color, 4=symbol shape, 5=symbol interior, 6=symbol size. Except for pattern color (defined in the Pattern tab, all other plot elements are controlled in the Symbol tab of the plot.
For a particular plot style, not all values are valid. An invalid entry will be indicated by a red x in a red box or a hollow black square.

### Examples:

Legend Entry Description
Edge Color %(CategoricalDa,@LM,4)
\l(1, m1, 1) %(1, m1, 1)
\l(1, m2, 1) %(1, m2, 1)
\l(1, m3, 1) %(1, m3, 1)
The edge color of the symbol is controlled by a categorical dataset.
Color  %(CategoricalDa,@LM,3)
\l(1,m1,1) %(1,m1,1)
\l(1,m2,1) %(1,m2,1)
The symbol color is controlled by a categorical dataset.
Fill Color  %(CategoricalDa,@LM,5)
\l(1, m1, 2) %(1, m1, 2)
\l(1, m2, 2) %(1, m2, 2)
\l(1, m3, 2) %(1, m3, 2)
The fill color of the symbol is controlled by a categorical dataset.
\l(1,m1,8 1 2 3) %(1,m1,8)
\l(1,m2,8 1 2 3) %(1,m2,8)
\l(1,m3,8 1 2 3) %(1,m3,8)
The fill pattern is controlled by a categorical dataset.
\l(1,m1,3) %(1,m1,3)
\l(1,m2,3) %(1,m2,3)
The pattern color is controlled by a categorical dataset.
Shape  %(CategoricalDa,@LM,6)
\l(1, m1, 4) %(1, m1, 4)
\l(1, m2, 4) %(1, m2, 4)
\l(1, m3, 4) %(1, m3, 4)
The symbol shape is controlled by a categorical dataset (2D Symbol Only).
Interior  %(CategoricalDa,@LM,7)
\l(1, m1, 5) %(1, m1, 5)
\l(1, m2, 5) %(1, m2, 5)
\l(1, m3, 5) %(1, m3, 5)
\l(1, m4, 5) %(1, m4, 5)
The symbol interior is controlled by a categorical dataset. (2D Symbol Only)
Size  %(CategoricalDa,@LM,3)
\l(1, m1, 6) %(1, m1, 6)
\l(1, m2, 6) %(1, m2, 6)
The symbol size is controlled by a categorical dataset.

## Legend for Box Chart Components

The legend for box chart components uses a special syntax:

### Legend Data Plot Symbol

\L(PlotIndex,ComponentChar)

### Legend Text Substitution

%(PlotIndex, @V"Box_ComponentChar")

### Arguments:

• PlotIndex: An integer which defines the data plot number.
• ComponentChar: One or more characters to define a component of the box chart. Note how in Text Substitution, the characters are preceded with Box_ and enclosed in double quotes.

The following table summarizes all available values for ComponentChar.

Character(s) Description (Substituted Text) Example
B The box.

This character can only be used for legend data plot symbol.

\L(1,B)
R The box range. (e.g. 25%~75%)

This character can only be used for legend text substitution.

%(1, @V"Box_R")
W The whisker of box. (e.g. Outlier) \L(1,W) %(1,@V"Box_W")
MDL The median line of the box. (Median Line) \L(1,MDL) %(1,@V"Box_MDL")
ML The mean line of the box. (Mean Line) \L(1,ML) %(1,@V"Box_ML")
Max The max percentile point of the box. (Max) \L(1,Max) %(1,@V"Box_Max")
P99 The 99% percentile point of the box. (99%) \L(1,P99) %(1,@V"Box_P99")
M The mean percentile point of the box. (Mean) \L(1,M) %(1,@V"Box_M")
P1 The 1% percentile point of the box. (1%) \L(1,P1) %(1,@V"Box_P1")
Min The minimum percentile point of the box. (Min) \L(1,Min) %(1,@V"Box_Min")
D The data points of the box. (Data) \L(1,D) %(1,@V"Box_D")
O The outlier of the box. (Outliers) \L(1,O) %(1,@V"Box_O")

## Independent Symbol in Legend

A legend symbol can be manually created and need not reference any actual data.

The following four kinds of syntax can be used in different occasions, depending on what kind of symbols you would like to use.

 \L(O SymEdgeColor,Sym,Fill,Size,ColorLn,LineStyle,Gap,LnWidth,SymFillColor,EdgeThickness) \L(S 0, Sym, Fill, SymEdgeColor, SymFillColor, Size, LineStyle, ColorLn, LnWidth, Gap, EdgeThickness) \L(S 1, SymIndex, SymEdgeColor, Size, , , LineStyle,ColorLn, LnWidth, Gap) \L(S 1,CharIndex,CharColor,Size,Font,FontStyle,LineStyle,ColorLn, LnWidth, Gap)

Note: For the \L(S ) type of syntax, defining the first variable as 0 means to use an Origin built-in symbol, and defining it as 1 means to use a user-defined symbol or an ASCII character.

The definition of each variable is listed below:

Argument Description
SymEdgeColor From Origin Color index: 1...24 (1=Black,2=Red, etc.) or 24...40 if user-defined colors exist.
From HTML hex code: e.g. #ff0000 (do not surround with double-quotes as is required when using with the color() function).
Sym Symbol to use from Origin Shape index (0=no symbol, 1=square, 2=circle, 3=up triangle, 4=down triangle, 5=diamond, 6=cross, 7=cross(x), 8=asterix, 9=hbar, 10=vbar, 11=number, 12=LETTER, 13=letter, 14=right arrow, 15=left triangle, 16=right triangle, 17=hexagon, 18=star, 19=pentagon, and 20=sphere).
Fill Fill to use in symbol from Origin Interior index (0=solid, 1=open, 2=dot center, 3=hollow, 4=plus center, 5=x center, 6= hbar center, 7=vbar center, 8=half up, 9=half right, 10=half down, and 11=half left).
Size Symbol Size in Points.
ColorLn From Origin Color index or from HTML hex code (see SymEdgeColor).
LineStyle Line Style from Origin Line Styles (0=Solid, 1=Dash, 2=Dot, 3=Dash Dot, 4=Dash Dot Dot, 5=Short Dash, 6=Short Dot, 7=Short Dash Dot).
Gap Gap between Symbol and Line in percent of Symbol Size.
LnWidth Line Thickness in Points.
SymFillColor From Origin Color index or from HTML hex code (see SymEdgeColor).
EdgeThickness Symbol Edge Thickness in percent from 0 to 100.
SymIndex The order of the user defined symbol in the User-defined Symbols Grid. Allow integer input from 1 to 31.
CharIndex The ASCII code of the character. Allow integer input from 32 to 255.
CharColor The color index of the ASCII character. (see SymEdgeColor).
Font The index number of a particular font in your font list. To get the index number for a font, run font(fontname)= in the Script Window or Command Window.
Font Style The index number of font style (Underline, Italic, Bold). 0=no style, 1= Underline only, 2=Italic only, 3=Underline+Italic, 4=Bold only, 5=Underline+Bold, 6=Italic+Bold, 7=Underline+Italic+Bold.
 When one variable is left as empty, the default value will be used for this variable. The syntax \L(O SymEdgeColor,Sym,Fill,) will use the default value for all variables after Fill. You can also use these worksheet cell access notations to define one of the variables using a worksheet cell value.

A simpler syntax is available to create a Line Legend Symbol.

\L(L Color, Thickness, Style)

Argument Description
Color Line Color from Origin Color index: 1..24 (1=Black, 2=Red, etc.) or 24..40 if user-defined colors exist.
Thickness Line Thickness in Points.
Style Line Style from Origin Line Styles (0=Solid, 1=Dash, 2=Dot, 3=Dash Dot, 4=Dash Dot Dot, 5=Short Dash, 6=Short Dot, 7=Short Dash Dot).

## Legend Text Customization

The legend substitution is a special kind of %( ) substitution notation. It has the following syntax:

%([LayerIndex.]PlotIndex[Axis] [,@option])

Without the @option the default behavior is determined by the Legends/Titles tab in the Plot Details dialog of the graph. (Use Format:Page Properties to open the dialog.)

Note that for the PlotIndex part, if symbol color/size is defined by a dataset, you may use the special syntax ?R or ?S to refer to the color mapping/indexing (?R) or size indexing (?S) dataset.

To combine multiple @options interspersed with arbitrary text, use the following syntax:

%(PlotIndex,@(@option1+@option2+...))

An example for this combination is that, when you use the expression %(1,@(@LL(@LU))), the text will be a combination of long name and unit in the form of Long Name(Units). Within the inner parenthese you can mix arbitrary text as in: %(1X,@(Long Name @LL, Units @LU, Comments @LC))

### List of @Options

Below are some frequently used examples of the @options for customizing legend text. For the complete of all @options, see the @ text-label options

 Note: While many of these "@" label options can only apply to workbook data, some of them are applicable to matrix data, for example: %(1,@W) // returns the matrix book short name.
@option Substitute Text From... Example
@D Dataset name %(1,@D) --> Book1_B
@LA Long Name, if available, else Short Name. %(1,@LA) --> Delta Temperature
@LC Comments, if available, else Long Name, otherwise Short Name %(1,@LC) -->
YBCO
milled
@LCn The nth line of the Comments field. %(1,@LC2) -->milled
@LG Long Name (if not available then Short Name) and Units (if present). Equivalent to @U. %(1,@LG) -->Delta Temperature (K)
@LHn The name of the nth User-Defined Parameter.@LH1 is equivalent to @LH. %(1,@LH3) -->RunNo
@LL Column Long Name. Returns missing value if Long Name does not exist. %(1,@LL) --> Delta Temperature
@LM 1st line of Comment, if available, else Long Name, otherwise Short Name. %(1,@LM) --> YBCO
@LN 1st line of Comments (if not available then Long Name, otherwise Short Name) and Units. Equivalent to @(@LM(@LU)). %(1,@LN) --> YBCO(K)
@LPn The nth System Parameter. @LP is the same as @LP1. %(1,@LP2) --> 12/15/2004
@LQn The nth User-Defined Parameter and Units (if available). %(1,@LQ2) --> 235(K)
@LS Column Short Name, equivalent to @C %(1,@LS) --> B
@LU Units %(1,@LU) --> K
@R Dataset range %(1,@R) -->

[Book1]"Trial Run 2"!Col("Delta Temperature")[1:32]

@R1 Dataset range, minus row range %(1,@R1) -->

[Book1]"Trial Run 2"!Col("Delta Temperature")

@RB Dataset range, beginning row index %(1,@RB) -->1
@RE Dataset range, ending row index %(1,@RE) -->32
@RN Dataset range, total number of plotted points %(1,@RN) -->32
@W Short Name of workbook. %(1,@W) -->Book1
@WCn The nth line of the WorkBook Comment. If n is not specified, only the first line will be shown. %(1,@WC2) -->

<Origin EXE Folder>\Samples\Curve Fitting

@WL Long Name of workbook %(1,@WL) -->S21-235-07
@WMn The nth line of the WorkSheet Comment. If n is not specified, only the first line will be shown. %(1,@WM) -->Data imported from
@WP Project Explorer (PE) path of the workbook %(1,@WP) -->/Folder1/
@WS Name of the worksheet %(1,@WS) -->Trial Run 2

Note: When units are displayed in the legend, the English and Japanese versions of Origin enclose the units in parentheses (), while the German version uses square-brackets [].

### Worksheet Cell Access

There are also three special @options for worksheet cell assess, in which @V and @WT are used mostly for the point-by-point legend:

@option Substitute Text From... Example
@L, n The X value of the nth point in the data plot.
• %(1, @L, 2)
means the X value of the 2nd data point in the 1 data point.
@V, n The Y value of the nth point in the data plot.
•  %(1Y, @V, 2)
means the Y value of the 2nd data point in the 1st data plot.
@WT, ColIndex/ColName, RowIndex The worksheet cell value specified by the column index (or short name) and row index.
• %(1, @WT, 2, 3)
means the cell value at column 2, row 3 in the source worksheet of the 1st data plot.
• %(1, @WT, B, 3)
means 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.

### Text Format Customization

You can also customize the text format by escape sequences. Several frequently used examples are provided below:

Use this syntax... ...to format text Example
\+(text) Superscript  %(1)\+(2)
\-(text) Subscript  %(1)\-(n)
\g(text) Greek Letters \g(m)
\b(text) Bold \b(Important)
\i(text) Italic \i(%(1))
\u(text) Underline \u(%(1X,@L))

### Legend Element Alignment

To specify the alignment properties for symbol and text in legend, you need to activate the graph, and run the script below in Script Window:

legend.align=1;   //turn on the alignment mode

Then, you can right click the legend to select Properties to open the dialog, and add \^() as cell anchor, which set alignment for the object on the right side of anchor, \^(l), \^(c), \^(r) are LEFT, CENTER and RIGHT alignment respectively, for example:

After clicking OK, the legend will be shown the same as the preview in dialog.

Alternatively, you can press Ctrl and drag to re-arrange the legend:

For instance, you can make symbol C at the right side of symbol B by using Ctrl+drag. In this case, you need to use \^(lu), \^(cc), \^(ru) instead \^(l), \^(c), \^(r) between symbol and text:

In this way, the symbol and corresponding text will be treated as one group when Ctrl+drag rearranging, as shown below:

Otherwise, the symbol and corresponding text will be separated when Ctrl+drag rearranging: