PlotLegends

PlotLegends

is an option for plot functions that specifies what legends to use.

Details

  • Typical settings for PlotLegends include:
  • Noneadd no legend
    Automaticuse automatic legending
    "Expressions"use formulas as legend labels
    {lbl1,lbl2,}use lbli for the i^(th) input
    expruse expr as legend
    Placed[lspec,]specify placement of legend
  • The following legend constructors can be used to form commonly occurring legends: SwatchLegend, LineLegend, PointLegend, and BarLegend.

Examples

open allclose all

Basic Examples  (4)

Use editable placeholders as the legend for a plot:

Use the expressions being plotted as the legend:

Specify the text for a legend:

Place the legend above the plot:

Scope  (5)

Legend Content  (2)

Use LineLegend to construct a legend:

Use SwatchLegend to construct a legend:

BarLegend is used in ContourPlot and DensityPlot:

Use SwatchLegend to construct a legend:

A legend can be any expression:

Legend Placement  (3)

Use Placed to change legend placement:

Use named horizontal and vertical positions to place a legend:

Use scaled coordinates associated with plot range to place a legend:

For fine-control legend placement, specify the position where a legend should be placed:

Possible Issues  (1)

Control variables in Manipulate are shown in legend with full context due to the HoldForm:

Use With to show the variable value:

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

Text

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

BibTeX

@misc{reference.wolfram_2021_plotlegends, author="Wolfram Research", title="{PlotLegends}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/PlotLegends.html}", note=[Accessed: 03-August-2021 ]}

BibLaTeX

@online{reference.wolfram_2021_plotlegends, organization={Wolfram Research}, title={PlotLegends}, year={2012}, url={https://reference.wolfram.com/language/ref/PlotLegends.html}, note=[Accessed: 03-August-2021 ]}

CMS

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

APA

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