This is an archived page, please click here to view the latest updates.
The graph legend is a specialized Origin text object that uses a hidden variable notation to dynamically link to the workbook/worksheet data that it depicts. When a legend is created, Origin names the text label "Legend" in order to uniquely identify it and to ensure that the object behaves as a legend. The name of the legend object is visible in the legend's Programming Control dialog box (Format: Programming Control, with the legend object selected).
Note, too, the Link to (%,$), Substitution Level drop-down list is 1, which allows the legend object to be dynamically linked to the source data.
Most users will find Origin's improved default legend display options to be sufficiently flexible as to make manual editing of the legend object unnecessary. However, if you wish to have more control over the graph legend display, you may find the following information to be helpful.
Because the legend object is a specialized text object with a name ("Legend") that has particular significance inside Origin, you must rename it in order to preserve the customizations that are discussed in this section. Otherwise, any action that refreshes the legend object will likely overwrite your customizations. Once you rename the legend object, it becomes a static object and is no longer under Origin's control.
To rename the legend object:
As mentioned, the default legend is created using a LabTalk variable notation. This notation can be seen, in part, when you double-click on the legend to enter edit mode. Once you are in edit mode, you simply highlight the text that you want to change and type over it.
This is probably most useful in situations where you have customized the plot symbol of a single data point and you wish to add some explanatory text to the legend.
To view the legend's variable notation in full, you must open the legend's Object Properties dialog box:
Right-click on the legend object and select Properties... from the shortcut menu.
In the Object Properties dialog box, the general notation for the legend display is:
where the \l() switch creates the legend's data plot symbol and DataListPosition is the data plot's position in the data list at the bottom of the Data menu. This is a list of all plots in the active graph layer. Grouped data plots are preceded by a "g" in the plot list. The number following the letter "g" identifies the member of a group (since it is possible to have multiple groups within a layer).
The following syntax can be used to create a legend for different elements in a layer's dataplot.
where plot_index is the index of the dataplot in the current layer, and element_index is the index of the element in the dataplot.
It is useful to customize a legend in a dataplot with a dataset to control plot attributes, e.g. color, or a dataplot including customized elements.
For example, we use a category column Drug as the symbol's Indexing Color in a scatter plot, which includes three groups Drug A, Drug B, and Placebo. The categories for the 1st, 3rd, and 5th points are Drug A, Drug B, and Placebo, respectively.
Type the following syntax in the legend's Object Properties dialog box:
\l(1,1) Drug A
\l(1,3) Drug B
The legend would look like this:
You can use the following @letter arguments to modify the %(DataListPosition) notation. For example, to modify the first legend entry so that it displays the data range notation, you could enter the following in the Object Properties dialog box:
Below is a partial list of variable options for legend text (for a complete list of options, please refer to Text Label Options) :
|Use this @letter argument...||...to display this text in the legend||Example|
|@LA||Long Name if available (otherwise Short Name)||Magnesium|
|@LHn||The row header of the nth User-Defined Parameter.
This notation is also supported for WorkSheet access. For example, the following notation
will show the row header name of the second User-Defined Parameter in Book2, Sheet1. The index "1" is needed since this notation on WorkSheet is column specific, but you can enter any column index that is valid.
|@LQn||The nth User-Defined Parameter + Unit if available||Annealing Temperature (C)|
|@LU||Units (not including Long Name)||(?g/ml)|
|@LC||Comment if available, otherwise Long Name, otherwise Short Name||trial run|
|@LCn||The nth line of Comment||say, there are two lines in the Comment of the first column:
%(1,@LC2) refers to the second line, that is, 15C.
|@LG||Long Name if available (otherwise Short Name) + Unit||Magnesium (?g/ml)|
|@LM||Comment if available, otherwise Long Name, otherwise Short Name.||trial run|
|@PCn||The nth line of the WorkBook Comment. If n is not specified, all lines will show.||Magnesium Measurement|
|@LN||Comment if available (otherwise Long Name, otherwise Short Name) + Unit.||trial run (?g/ml)|
|@WCn||the nth line of the WorkBook Comment. If n is not specified, only the first line will show.||Magnesium Measurement|
|@WMn||the nth line of the WorkSheet Comment. If n is not specified, only the first line will show.||Magnesium Measurement|
Note that to use substitution notation (%,$) in an ordinary Origin label object, you must also set the Link to (%,$), Substitution Level to 1 in the Programming Control dialog box. In the case of the legend object, Link to (%,$), Substitution Level is 1 by default.
From Origin 9.0, it is possible to combine the text labels to form your user-defined label. For example to use "@LL[@LU]" means that the label is defined as "long name[unit]", and to use @LL-test-@LC means that the label is defined as "long name-test-comments".