({{, (RefLink[PointLegend, paclet:ref/PointLegend])[{(Subscript[col, 1]),…},{(Subscript[lbl, 1]),…}] 
generates a legend that associates points of colors (Subscript[col, i]) with labels (Subscript[lbl, i]).}, {, (RefLink[PointLegend, paclet:ref/PointLegend])[{(Subscript[col, 1]),…},Automatic]
generates a legend with placeholder labels for the colors (Subscript[col, i]).}, {, (RefLink[PointLegend, paclet:ref/PointLegend])[{(Subscript[lbl, 1]),…}]
represents a legend with inherited colors within visualization functions.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[PointLegend, paclet:ref/PointLegend]) uses a point with color (Subscript[col, i]) to identify label (Subscript[lbl, i]) with elements in a visualization or other legended item.

(RefLink[Legended, paclet:ref/Legended])[expr,PointLegend[…]] can be used to apply a legend to an arbitrary expression expr.

The following options can be given:

(RefLink[PointLegend, paclet:ref/PointLegend]) is displayed in (RefLink[StandardForm, paclet:ref/StandardForm]) as a table. In (RefLink[InputForm, paclet:ref/InputForm]), it is displayed as an explicit list of colors and labels.

In (RefLink[PointLegend, paclet:ref/PointLegend]), (RefLink[LegendLayout, paclet:ref/LegendLayout]) can have the following forms:

The layout specification f is applied to the table of values {{(Subscript[col, 1]),(Subscript[lbl, 1])},…} to generate the legend.

(RefLink[LegendFunction, paclet:ref/LegendFunction]) is applied to the legend, including any overall label and margins.

OpenersPrimaryExamplesSection(Spacer1)Examples  (45)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

A list of styles and labels:

PointLegend[{Red,Green,Blue},{"red","green","blue"}]

Use placeholder labels:

PointLegend[{Red,Green,Blue},Automatic]

(RefLink[PointLegend, paclet:ref/PointLegend]) is used to automatically create legends for (RefLink[ListPlot, paclet:ref/ListPlot]):

ListPlot[{(Sqrt[Range[50]]),((Range[50])^(1/3))},PlotLegends->{"one","two"}]

Customize the appearance of the legend:

ListPlot[{(Sqrt[Range[50]]),((Range[50])^(1/3))},PlotLegends->PointLegend[Automatic,{"one","two"},LegendFunction->"Frame",LegendLabel->"datasets"]]

OpenersExampleSection1(Spacer1)Scope  (14)

OpenersExampleSubsection0(Spacer1)Styles and Labels  (9)

Use style primitives:

PointLegend[{Red,Green,Blue},{"label1","label2","label3"}]

Use with markers:

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendMarkers->Automatic]

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendMarkers->{Graphics[Disk[]],Graphics[Rectangle[]],Graphics[Circle[]]}]

Use (RefLink[Directive, paclet:ref/Directive]) to combine directives in a style:

PointLegend[{Directive[Red,AbsolutePointSize[4]],Directive[Blue,AbsolutePointSize[6]],Directive[Green,AbsolutePointSize[8]]},{"label1","label2","label3"}]

(RefLink[PointLegend, paclet:ref/PointLegend]) uses the shorter list of styles and labels:

PointLegend[{Red,Green,Blue},{"label1","label2","label3","label4"}]

Use indexed colors:

PointLegend[63,{"label1","label2","label3"}]

Use gradient color schemes:

PointLegend["Rainbow",Range[5]]

Use (RefLink[Placeholder, paclet:ref/Placeholder]) labels:

PointLegend[{Red,Blue,Green},Automatic]

(RefLink[PointLegend, paclet:ref/PointLegend]) remains unevaluated in other cases:

PointLegend[Automatic]

PointLegend[Automatic,{"label1","label2","label3"}]

(RefLink[PointLegend, paclet:ref/PointLegend]) normally displays in tabular form:

PointLegend[{Hue[0.05],Hue[0.1],Hue[0.15]},{"one","two","three"}]

(RefLink[InputForm, paclet:ref/InputForm]) shows a textual form:

InputForm[%]

OpenersExampleSubsection1(Spacer1)Presentation  (5)

(RefLink[PointLegend, paclet:ref/PointLegend]) line wraps automatically:

PointLegend[63,Range[20]]

PointLegend["Rainbow",Range[20],LegendLayout->"Row"]

(RefLink[PointLegend, paclet:ref/PointLegend]) automatically picks up styles when used in plots:

ListPlot[RandomReal[1,{2,50}],PlotStyle->{Orange,Brown},PlotLegends->PointLegend[{"aaaaa","zzzzz"}]]

(RefLink[PointLegend, paclet:ref/PointLegend]) automatically picks up (RefLink[PlotMarkers, paclet:ref/PlotMarkers]):

ListLinePlot[RandomReal[1,{2,10}],PlotStyle->63,PlotMarkers->Automatic,PlotLegends->PointLegend[{"aaaaa","zzzzz"},LegendMarkers->Automatic]]

Change the default look of (RefLink[PointLegend, paclet:ref/PointLegend]) and the position:

ListPlot[Transpose@Table[{Sin[x],Cos[x]},{x,0,2π,0.1}],PlotStyle->{Blue,Red},PlotLegends->Placed[PointLegend[{"sin(x)","cos(x)"},LegendFunction->"Frame",LegendLayout->"Column"],{{0.7,1},{0.5,1}}]]

Use (RefLink[Legended, paclet:ref/Legended]) to legend (RefLink[Graphics, paclet:ref/Graphics]) with (RefLink[PointLegend, paclet:ref/PointLegend]):

pts1={{0,-1},{2,1},{4,2},{6,2}};
pts2={{2,-1},{3,1},{4,-1},{6,0}};

Legended[Graphics[{Blue,BezierCurve[pts1],Red,BezierCurve[pts2],Orange,BezierCurve[Mean[{pts1,pts2}]]},Frame->True],PointLegend[{Blue,Red,Orange},{"curve1","curve2","mean"}]]

OpenersExampleSection2(Spacer1)Options  (28)

OpenersExampleSubsection2(Spacer1)Joined  (4)

By default, no lines are drawn:

ListPlot[{Range[10],Prime[Range[10]]},Joined->{True,False},PlotLegends->PointLegend[{"one","two"}]]

(RefLink[Joined, paclet:ref/Joined])->(RefLink[Automatic, paclet:ref/Automatic]) matches the behavior of the plot:

ListPlot[{Range[10],Prime[Range[10]]},Joined->{True,False},PlotLegends->PointLegend[{"one","two"},Joined->Automatic]]

(RefLink[Joined, paclet:ref/Joined])->(RefLink[True, paclet:ref/True]) always draws lines:

ListPlot[{Range[10],Prime[Range[10]]},Joined->{True,False},PlotLegends->PointLegend[{"one","two"},Joined->True]]

(RefLink[Joined, paclet:ref/Joined]) can take a list of values:

ListPlot[{Range[10],Prime[Range[10]]},Joined->{True,False},PlotLegends->PointLegend[{"one","two"},Joined->{True,False}]]

OpenersExampleSubsection3(Spacer1)LabelStyle  (3)

All labels have the same default style:

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendLabel->"legend"]

Specify styles for labels:

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LabelStyle->Red]

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LabelStyle->20]

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LabelStyle->{FontFamily->"Helvetica"}]

(RefLink[LabelStyle, paclet:ref/LabelStyle]) applies to (RefLink[LegendLabel, paclet:ref/LegendLabel]):

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LabelStyle->{Bold,18,Gray},LegendLabel->"legend"]

OpenersExampleSubsection4(Spacer1)LegendFunction  (4)

Use a stylized frame:

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendFunction->"Frame"]

Use (RefLink[Panel, paclet:ref/Panel]):

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendFunction->"Panel"]

Use a customized frame:

frame[legend_]:=Framed[legend,FrameStyle->Red,RoundingRadius->10,FrameMargins->0,Background->LightGreen]

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendFunction->frame]

Create a legend with a drop shadow:

shadowbox[legend_]:=Graphics[{{Gray,Rectangle[{0.05,-0.05},{1.05,0.95}]},{White,EdgeForm[Gray],Rectangle[]},Inset[legend,{0.5,0.5},Center]},ImageSize->80]

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendFunction->shadowbox]

OpenersExampleSubsection5(Spacer1)LegendLabel  (5)

Add an overall label to the legend:

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendLabel->"legend"]

The label from (RefLink[LegendLabel, paclet:ref/LegendLabel]) is included in the argument to (RefLink[LegendFunction, paclet:ref/LegendFunction]):

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendFunction->Framed,LegendLabel->"legend"]

Construct a (RefLink[LegendFunction, paclet:ref/LegendFunction]) using (RefLink[Labeled, paclet:ref/Labeled]) that has a label outside:

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendFunction->(Labeled[Framed[#],"legend",Top]&)]

Use (RefLink[LabelStyle, paclet:ref/LabelStyle]) to style a legend label:

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendLabel->"legend",LabelStyle->{Brown,FontSize->16,Italic}]

Use (RefLink[Placed, paclet:ref/Placed]) to change the legend label position:

Table[PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendFunction->"Frame",LegendLabel->Placed["legend",pos]],{pos,{Left,Top,Bottom,Right}}]

Use the third argument in (RefLink[Placed, paclet:ref/Placed]) to rotate the legend label:

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendFunction->"Frame",LegendLabel->Placed["legend",Left,Rotate[Style[#,Large],90Degree]&]]

OpenersExampleSubsection6(Spacer1)LegendLayout  (4)

Arrange the legend in a row:

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendLayout->"Row"]

Arrange the legend in a column:

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendLayout->"Column"]

Reverse the direction of the legend:

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendLayout->"ReversedRow"]

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendLayout->"ReversedColumn"]

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

table[pairs_]:=TableForm[pairs,TableHeadings->{{"Group A","Group B","Group C"},{"color","mascot"}},TableAlignments->Center]

PointLegend[63,{"lion","whale","rocket"},LegendLayout->table]

OpenersExampleSubsection7(Spacer1)LegendMargins  (3)

Leave no space between the legend content and any boundaries from (RefLink[LegendFunction, paclet:ref/LegendFunction]):

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendFunction->"Frame",LegendMargins->0]

Specify a margin around the content:

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendFunction->"Frame",LegendMargins->10]

Use different margins on different sides:

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendFunction->"Frame",LegendMargins->{{10,0},{20,10}}]

OpenersExampleSubsection8(Spacer1)LegendMarkers  (3)

By default, points are drawn:

ListPlot[{Range[10],Prime[Range[10]]},PlotMarkers->Automatic,PlotLegends->PointLegend[{"one","two"}]]

(RefLink[LegendMarkers, paclet:ref/LegendMarkers])->(RefLink[Automatic, paclet:ref/Automatic]) matches the markers used by the plot:

ListPlot[{Range[10],Prime[Range[10]]},PlotMarkers->Automatic,PlotLegends->PointLegend[{"one","two"},LegendMarkers->Automatic]]

Specify a shape to use:

ListPlot[{Range[10],Prime[Range[10]]},PlotLegends->PointLegend[{"one","two"},LegendMarkers->"◆"]]

OpenersExampleSubsection9(Spacer1)LegendMarkerSize  (2)

Specify the size of legend items in every direction:

Table[PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendMarkerSize->i],{i,{10,20,30}}]

Specify sizes for the width and height:

PointLegend[{Red,Green,Blue},{"label1","label2","label3"},LegendMarkerSize->{{5,25}}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[LineLegend, paclet:ref/LineLegend])  ▪  (RefLink[SwatchLegend, paclet:ref/SwatchLegend])  ▪  (RefLink[BarLegend, paclet:ref/BarLegend])  ▪  (RefLink[Legended, paclet:ref/Legended])  ▪  (RefLink[PlotLegends, paclet:ref/PlotLegends])  ▪  (RefLink[ChartLegends, paclet:ref/ChartLegends])  ▪  (RefLink[ListPlot, paclet:ref/ListPlot])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Legends, paclet:guide/Legends])}, {▪(RefLinkPlain[Chart Labeling, Legending & Annotation, paclet:guide/ChartLabelingLegendingAndAnnotation])}, {▪(RefLinkPlain[Labels, paclet:guide/Labels])}})}})