8.10 Graph Legends
Origin supports four legend objects and two scale objects. This page focuses on legend objects. For information on scale objects, see Color Scales and Bubble Scales.
Graph Legend Components
The four graph legends above share the following components:
The graph legend is a special text object that is automatically created on the graph page. The legend object is given a specific name -- "Legend" -- and programmatically linked to your Origin project data using LabTalk notation. You will not see this notation unless you are editing the legend object. Normally, what displays is the "translated" symbol and legend text.
This image of a typical legend's Object Properties dialog box shows the LabTalk notation in the center of the dialog and the "translated" legend symbol and legend text -- what you actually see on the graph page -- in the lower part of the dialog.
Since the legend is a text object, you can edit it using methods common to all text objects:
- Double-click on the graph legend to enter "in-place" edit mode.
- Right-click on the legend object and choose Properties.
General Legend Customizations
- To delete a legend object:
- Click to select the legend then press the Delete key, or right-click and choose Delete from the shortcut menu.
- To show or hide the legend background:
- Right-click on the legend object and choose Properties from the shortcut menu. Set Background to None, Black Line, Shadow, Dark Marble, White Out or Black Out.
- To modify thickness or color of the line around the legend object (Background = Black Line):
- Click to select the legend object. Use the Line/Border Color button on the Style toolbar to edit line color. Use the Line/Border Width list to set the line width.
- Select the legend object, then drag one of the green handles.
- To arrange legend entries into multiple columns:
- Select the 2D legend object, then hold Ctrl key to drag one of the green handles to arrange the legend entries into multiple columns.
- To adjust padding between legend entries and the background:
- Point to outside edge of the legend object and when the pointer becomes a "hand", click once to show handles. Drag a handle to add or subtract padding.
- To increase the legend symbol width (the horizontal space devoted to the legend symbol):
- Right-click on graph and choose Plot Details. At the graph page level, click the Legends/Titles tab, then enter a Legend Symbol Width (% of Font) (Note that the effect of this control varies depending upon plot type; for instance, it has no effect on symbol size of a line + symbol plot but it will increase the length of the line segment).
- To change the line spacing between legend entries:
- Right-click on the legend object and choose Properties. Edit the Line Spacing (%) list (enter value or choose from list).
- To add a title to your legend:
- Double-click on the legend text to enter "in-place" edit mode and insert your text directly into the legend object. Use the tools on the Format toolbar to format your text (including any substitution notation text).
- To modify the legend text:
- Click on the legend object to select it, then use the buttons on the Format toolbar. Note that some buttons will not be active unless you are in "in-place" edit mode (double-click to enter).
|Notes: To make the legend text color follow the legend symbol color such as
- Set the font color as Auto on the Format toolbar or right-click the legend to select the Properties from the context menu to set the color to Auto in the Object Properties dialog.
- Right-click on the legend object and choose Legend: Text Color Follows Plot.
- To add special characters (symbols, Greek characters, etc.) to the legend:
- Double-click on the legend text to go into "in-place" edit mode, then use the Font or Greek tools on the Format toolbar; or open the Symbol Map by right-clicking and choosing Symbol Map from the shortcut menu.
Customizing the Data Plot Legend
The Data Plot Legend is the most common legend for many 2D and some 3D graphs.
Before proceeding to customize the data plot legend, you should know the difference between "updating" a legend and "reconstructing" a legend: Updating will preserve your customizations, reconstructing will not.
You can actively update or reconstruct the legend using shortcut menu commands (Update Legend or Reconstruct Legend) or by clicking the Reconstruct Legend toolbar button but be aware that there is also a Legend Update Mode setting at the page level in the graph's Plot Details dialog box. If you are adding or removing data plots from your graph, know that you could overwrite legend customizations if this control is set to Reconstruct....
- To update the legend object when adding or removing plots from the graph:
- Activate the graph and click Format: Page Properties. Click the Legends/Titles tab and set Legend Update Mode to Reconstruct when Adding/Removing or Update when Adding. If you set Legend Update Mode to None, you can always right-click inside the graph layer and choose Legend: Reconstruct Legend or Legend: Update Legend to refresh the legend object.
- To construct a single legend for multiple layers:
- Right-click inside the graph layer and choose Legend: Update Legend. In the legendupdate dialog box, set Update Scope to Whole Page; Update Mode to Reconstruct; and Legend to One Legend for Whole Page.
- To reorder legend entries:
- Select the legend object, then right-click and choose Legend: Reverse Order (default legends only); or open the legendupdate dialog box and use the Order controls. If neither gives the result you want, reorder by cutting and pasting legend entries, either in "in-place" edit mode or in the legend object's Properties dialog box (click to select the legend object, then right-click and choose Properties).
- To show or hide certain legend entries:
- Sometimes you may want to hide legend entries for the hidden data plots, or the entries for fitted curve. In this case, you could right click on the legend object and select Legend:Show Legend for Visible Plots Only or Legend: Hide Legend for Fitted Curves.
- To hide legend symbol(s):
- Right-click on Legend to select Legend: Hide Legend Symbol from context menu to hide the symbols in Legend. This selection is equivalent to setting Legend Symbol Width to 0% in the Legend/Titles tab of Plot Details dialog.
- To modify the size of the legend symbol:
- Use the \L([LayerIndex.]PlotIndex[,PointIndex][,S:SizeOption]) syntax. The SizeOption can be specified in two ways: S:##, where ## is the point size of the plot symbol (upper-limit of approx. 16 pt); or S:p##, where p## is the percentage of the font size (values limited to 1 - 99). So, for example, the legend notation might read \l(3,s:24) %(3), where s:24 specifies a symbol size of 24 points; or \l(3,s:p50) %(3), where s:p50 specifies a symbol size that is 50% of font size. For a complete explanation of this notation, see Legend Substitution Notation.
- To insert information in worksheet column label rows into the legend text:
- Use the legendupdate dialog box. Right-click inside the graph layer and choose Legend: Update Legend. Choose a legend text option from Auto Legend Translation Mode. For more options, choose Custom then click the arrow to the right of Legend Custom Format (@D, @LU etc). Note that Custom allows header information to be concatenated.
- To manually insert worksheet column label row information into the legend text:
- Use the syntax %(PlotIndex,@option). To combine multiple @options interspersed with arbitrary text, use %(PlotIndex,@(@option1+@option2+...)) as shown below. See this topic for a complete list of @options.
- Another option for inserting worksheet-stored variable information into the legend text:
- Double-click on the legend text to enter "in-place" edit mode. Right-click and choose Insert Info Variables from the shortcut menu. For more information on the Insert Variables dialog box, see this page.
- To create a legend symbol that is completely independent of the plot symbol:
- Use the syntax outlined here.
- To ensure that your legend customizations cannot be overwritten by reconstructing:
- Rename the legend object. Right-click on the legend, choose Programming Control and change Object Name to something other than "Legend".
Customizing Special Legends
The four types of legend objects can co-exist in one graph. For example, you may have multiple Y datasets and plot them as a box chart. However, you would like to show both the data plot legend and the box chart component legend.
- Once a graph is created, clicking the Reconstruct Legend toolbar button will create the most appropriate legend for your graph.
- When you right-click a legend object and point to the Legend context menu, the 1st group in the sub-menu will show applicable legend objects for your graph. If you choose one of these legends, it will be appended to the existing legend. Note: Each type of legend object can only appear once.
- The same menu options are also available from the Graph menu and when right-clicking in the graph.
- Each special legend has a corresponding dialog for customizing the menu.
- Categorical Values Legend
- Point-by-Point Legend
- Box Chart Components Legend