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 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:
-
LabelStyle Automatic style to use for labels LegendFunction Identity wrapper for the overall legend LegendLabel None overall label for legend LegendLayout Automatic legend layout to use LegendMargins Automatic space between legend content and boundaries LegendMarkers Automatic markers to use to indicate each element LegendMarkerSize Automatic size 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:
-
Automatic automatically 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 f apply 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.
Examples
open allclose allScope (13)
Data (8)
Use Directive to combine directives in a style:
SwatchLegend uses the shorter list of styles and labels:
Placeholder is used by default:
SwatchLegend remains unevaluated in other cases:
SwatchLegend normally displays in tabular form:
InputForm shows a textual form:
Presentation (5)
SwatchLegend line wraps automatically:
SwatchLegend automatically picks up styles when used in plots:
Use automatic formulas as legends:
Change the default look of SwatchLegend and the position:
Use Legended to legend Graphics with SwatchLegend:
Options (23)
LabelStyle (3)
All labels have the same default style:
LabelStyle applies to LegendLabel:
LegendFunction (4)
LegendLabel (5)
Add an overall label to the legend:
The label from LegendLabel is included in the argument to LegendFunction:
Construct a LegendFunction using Labeled that has a label outside:
Use LabelStyle to style the legend label:
Use Placed to change the legend label position:
Use the third argument in Placed to rotate the legend label:
LegendLayout (4)
LegendMarkers (4)
Applications (1)
Legend a Graph object:
Text
Wolfram Research (2012), SwatchLegend, Wolfram Language function, https://reference.wolfram.com/language/ref/SwatchLegend.html.
CMS
Wolfram Language. 2012. "SwatchLegend." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SwatchLegend.html.
APA
Wolfram Language. (2012). SwatchLegend. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SwatchLegend.html