Ploticus > Scripts >
proc legendentry

Explicitly defines one legend entry. This entry will be rendered the next time that proc legend is executed. Usually, legends are built by successive plotting procs having a legendlabel attribute. However, if additional flexibility is needed to make custom legend entries, this proc may be invoked, once per legend entry.

For example, if a scatterplot is being created with various sized points, there is no automatic way to get a legend of the various point sizes, so proc legendentry could be executed (probably several times) to define legend information, then proc legend could be executed to render it.

proc legendentry is also useful in setting up legend-driven plots which allow things like bar color, or scatterplot symbol color, size, or shape to be controlled by a data field.

A gallery example that uses this proc is scatterplot3a.


sampletype     t

    The type of sample to be displayed with the entry. t may be one of: line, color, symbol, text, line+symbol, or text+symbol. It may also be none, in order to insert spacing into the legend.
    Example: sampletype: text

label     text

    The label for the legend entry. The \\n construct can be used to force a line break when the legend is displayed, or the label can be wordwrapped using proc legend wraplen attribute.
    Example 1: label: Eastern counties
    Example 2: label: Response curve \\n for 30 mg dose

tag     string

    An optional short identifier to be associated with the entry, so that the entry can be accessed later. Used with proc bars colorfield, as in this example: colorfld

details     spec
details2     spec
details3     spec

    Details regarding the rendering of the sample. Exactly what should be supplied for details, details2 and perhaps details3 depends on the sampletype:
    sampletype            details           details2        details3
    ----------          ------------      -------------   -----------
    line                linedetails       -               -
    color               color             -               -
    symbol              symboldetails     -               -
    text                a char or word    textdetails     -
    line+symbol         linedetails       symboldetails   -
    text+symbol         a char or word    textdetails     symboldetails
    Explanations of types: color     linedetails     symboldetails     textdetails

Legend-driven technique

This is a technique where the legend table mechanism serves to map certain data values to ploticus colors or other appearance attributes. For example, suppose field 3 of your data is a group code of either A, B, or C. You could use legend-driven technique to render 'A' data rows in red, 'B' in blue, and 'C' in green.

Here's how you do it:

    1. For every expected variation, set up an explicit legend entry using proc legendentry. label, tag, and details attributes should be supplied. The tag will be compared with data field contents. The details attributes control appearance.
    2. Plot, using the appropriate attribute. For example, if you are doing a bar graph where individual bar colors are controlled by a data field, you would use proc bars and specify a colorfield.

Examples of legend-driven technique are colorfld symfld symfld dupsleg


Ploticus 2.42 ... May 2013 Terms of use /