Legended
Details
- The content expr and legend leg in Legended[expr,leg] can be be anything, including graphics, tables, and images.
- Legended can be used as a symbolic wrapper for data elements and datasets in functions such as ListPlot and BarChart.
- The legend entry associated with Legended[expr,lbl] includes an identifying prototype, such as a color swatch, for expr, displayed with the label lbl.
- The label lbl in Legended[expr,lbl] can be any expression, including graphics.
- Legended[expr,Placed[…,pos]] can be used to create legends at different positions.
- Possible forms for pos are:
-
Above,Below,Before,After positions outside the bounding box for expr {h,v} horizontal h and vertical positions v {{ex,ey},{lx,ly}} scaled position {lx,ly} in the legend at scaled position {ex,ey} in expr - Possible horizontal positions include Before, Left, Center, Right and After.
- Possible vertical positions include Below, Bottom, Center, Top and Above.
- The legend leg will frequently be created by functions such as BarLegend and LineLegend.
Examples
open all close allBasic Examples (5)
Use Legended to provide legend entries for specific elements:
PieChart[{1, Legended[2, "Bob"], 3, Legended[4, "John"]}]Use Legended to provide a legend entry for a specific dataset:
data1 = RandomReal[{0, 1}, 25];
data2 = RandomReal[{1, 2}, 25];ListLinePlot[{data1, data2, Legended[Mean[{data1, data2}], "mean"]}]Plot[{BesselJ[2, x], BesselJ[3, x]}, {x, 0, 20}, PlotLegends -> Placed["Expressions", {Right, Top}]]Add a legend to a table of values:
Legended[Grid[Partition[Table[If[PrimeQ[n], Item[n, Background -> StandardBlue], n], {n, 100}], 10], Frame -> All], SwatchLegend[{StandardBlue}, {"prime numbers"}]]Legend a Graph object:
g = RandomGraph[{20, 100}];h = FindHamiltonianCycle[g];Legended[HighlightGraph[g, Style[h, Directive[Thick, Red]]], LineLegend[{Directive[Thick, Red]}, {"Hamiltonian cycle"}]]Scope (6)
Construct a legend for a graphic:
data = RandomVariate[NormalDistribution[], 100];Legended[Histogram[data], Column[{Row[{"max=", Max[data]}], Row[{"min=", Min[data]}]}]]Construct a legend for an image:
img = [image];Legended[img, Placed[ImageHistogram[img], Below]]Use Legended as a wrapper to specify a legend label for a single dataset:
ListLinePlot[{Sort[RandomReal[1, 100]], Legended[{{0, 0}, {1, 1}}, "reference"]}, DataRange -> {0, 1}]Specify a legend for a single value:
BarChart[{12, 23, 34, 38, 45, Legended[Style[56, Orange], "projected"]}, ChartStyle -> Gray]Use Placed to position the legend:
BarChart[{12, 23, 34, 38, 45, Legended[Style[56, Orange], Placed["projected", Below]]}, ChartStyle -> Gray]Place legends outside the legended object:
Table[Legended[Graphics3D[Sphere[]], Placed[Framed["legend"], p]], {p, {Before, After}}]Table[Legended[Graphics3D[Sphere[]], Placed[Framed["legend"], p]], {p, {Below, Above}}]Place legends inside the legended object:
Legended[Graphics3D[Sphere[]], Placed[Framed["legend", Background -> StandardGray], {{1, 1}, {1, 1}}]]Neat Examples (1)
Use Legended to add a legend to a stylized grid:
Legended[Grid[Apply[Item[Row[{Quantity[#2, "Hours"], " at ", Quantity[#, "Celsius"] }], Background -> If[#3 == 1, None, StandardBlue]]&, Transpose[Partition[ExampleData[{"Statistics", "MotorFailures"}], 10]], {2}], Frame -> All], Placed[SwatchLegend[{StandardBlue}, {"motor failure"}], Below]]Text
Wolfram Research (2008), Legended, Wolfram Language function, https://reference.wolfram.com/language/ref/Legended.html (updated 2012).
CMS
Wolfram Language. 2008. "Legended." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2012. https://reference.wolfram.com/language/ref/Legended.html.
APA
Wolfram Language. (2008). Legended. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Legended.html
BibTeX
@misc{reference.wolfram_2026_legended, author="Wolfram Research", title="{Legended}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/Legended.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_legended, organization={Wolfram Research}, title={Legended}, year={2012}, url={https://reference.wolfram.com/language/ref/Legended.html}, note=[Accessed: 13-June-2026]}