Skip to main content

Legended

Attaches legend or label to any expr

Legended[expr_, lbl_ | legend_]

One can use it to provide legend entries for specific elements

PieChart[{1, Legended[2, "Bob"], 3, Legended[4, "John"]}]

Add a legend to a table of numbers

Legended[ Grid[Partition[ Table[If[PrimeQ[n], Item[n, Background -> LightBlue], n], {n, 100}], 10], Frame -> All], SwatchLegend[{LightBlue}, {"prime numbers"}]]

note

Legended is used implicitly with provided options PlotLegends

Plot[{BesselJ[2, x], BesselJ[3, x]}, {x, 0, 20}, 
PlotLegends -> Placed["Expressions", {Right, Top}]]

Legend placement

Use Placed to adjust the position of your legend, i.e.

Legended[1/2, Placed[SwatchLegend[{Red}, {"Number"}], Before]]

Supported output forms