SwatchLegend

SwatchLegend[{col1,},{lbl1,}]
generates a legend that associates swatches of colors coli with labels lbli.

SwatchLegend[{col1,},Automatic]
generates a legend with placeholder labels for the colors coli.

SwatchLegend[{lbl1,}]
represents a legend with inherited colors within visualization functions.

Details and OptionsDetails and Options

  • SwatchLegend uses a shape with color coli to identify label lbli with elements in the visualization or other legended item.
  • Legended[expr,SwatchLegend[]] can be used to apply a legend to an arbitrary expression expr.
  • The following options can be given:
  • LabelStyleAutomaticstyle to use for labels
    LegendFunctionIdentitywrapper for the overall legend
    LegendLabelNoneoverall label for legend
    LegendLayoutAutomaticlegend layout to use
    LegendMarginsAutomaticspace between legend content and boundaries
    LegendMarkersAutomaticmarkers to use to indicate each element
    LegendMarkerSizeAutomaticsize of the shape
  • SwatchLegend is displayed in StandardForm as a table. In InputForm it is displayed as an explicit list of colors and labels.
  • In SwatchLegend, LegendLayout can have the following forms:
  • Automaticautomatically determine layout
    "Row"display legend in a horizontal row
    "Column"display legend in a vertical column
    "ReversedRow"display reversed legend in a horizontal row
    "ReversedColumn"display reversed legend in a vertical column
    fapply f to construct the legend
  • The layout specification f is applied to the table of values {{col1,lbl1},} to generate the legend.
  • With LegendLayout->Automatic, the layout used will depend on the location relative to the object being legended.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

A list of styles and labels:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Use default labels:

In[3]:=
Click for copyable input
Out[3]=

Used in plots:

In[4]:=
Click for copyable input
Out[4]=
Introduced in 2012
(9.0)
Translate this page: