LineLegend

LineLegend[{col1,},{lbl1,}]

generates a legend that associates color coli with label lbli.

LineLegend[{col1,},Automatic]

generates a legend with placeholder labels for the colors coli.

LineLegend[{lbl1,}]

represents a legend with inherited colors within visualization functions.

Details and Options

  • LineLegend uses a line with style coli through a marker to identify label lbli with curves and markers in the visualization or other legended item.
  • Legended[expr,LineLegend[]] can be used to apply a legend to an arbitrary expression expr.
  • The following options can be given:
  • Joined Truewhether to draw shapes
    LabelStyle Automaticstyle to use for labels
    LegendFunction Identitywrapper for the overall legend
    LegendLabel Noneoverall label for legend
    LegendLayout Automaticlegend layout to use
    LegendMargins Automaticspace between legend content and boundaries
    LegendMarkers Nonemarkers to use to indicate each element
    LegendMarkerSize Automaticsize of the shape
  • LineLegend is displayed in StandardForm as a table. In InputForm, it is displayed as an explicit list of colors and labels.
  • In LineLegend, 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.
  • LegendFunction is applied to the legend, including any overall label and margins.

Examples

open allclose all

Basic Examples  (1)

A list of styles and labels:

Use default labels:

Used in plots:

Scope  (15)

Data  (9)

Use style primitives:

Use with markers:

Use Directive to combine directives in a style:

LineLegend uses the shorter list of styles and labels:

Use indexed colors:

Use gradient color schemes:

Use Placeholder labels:

LineLegend remains unevaluated in other cases:

LineLegend normally displays in tabular form:

InputForm shows a textual form:

Presentation  (6)

LineLegend line wraps automatically:

LineLegend automatically picks up styles when used in plots:

LineLegend automatically picks up PlotMarkers:

Use expressions as legends:

Change the default look of LineLegend and the position:

Use Legended to legend Graphics with LineLegend:

Options  (27)

Joined  (3)

Joined->Automatic matches the behavior of the plot:

Joined->False always draws no lines:

Joined can take a list of values:

LabelStyle  (3)

All labels have the same default style:

Specify styles for labels:

LabelStyle applies to LegendLabel:

LegendFunction  (4)

Use a stylized frame:

Use Panel:

Use a customized frame:

Create a legend with a drop shadow:

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)

Arrange the legend in a row:

Arrange the legend in a column:

Reverse the direction of the legend:

Write a function to construct the legend as a formatted table:

LegendMargins  (3)

Leave no space between the legend content and any boundaries from LegendFunction:

Specify a margin around the content:

Use different margins on different sides:

LegendMarkers  (3)

By default, no markers are drawn:

LegendMarkers->Automatic matches the markers used by the plot:

Specify a shape to use:

LegendMarkerSize  (2)

Specify the size of legend items in every direction:

Specify sizes for the width and height:

Wolfram Research (2012), LineLegend, Wolfram Language function, https://reference.wolfram.com/language/ref/LineLegend.html.

Text

Wolfram Research (2012), LineLegend, Wolfram Language function, https://reference.wolfram.com/language/ref/LineLegend.html.

CMS

Wolfram Language. 2012. "LineLegend." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/LineLegend.html.

APA

Wolfram Language. (2012). LineLegend. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LineLegend.html

BibTeX

@misc{reference.wolfram_2024_linelegend, author="Wolfram Research", title="{LineLegend}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/LineLegend.html}", note=[Accessed: 19-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_linelegend, organization={Wolfram Research}, title={LineLegend}, year={2012}, url={https://reference.wolfram.com/language/ref/LineLegend.html}, note=[Accessed: 19-December-2024 ]}