How to | Make a Legend for My Charts

Mathematica provides an extensive, straightforward set of tools to control the appearance of your charts. Whether you are creating chart legends with the symbolic wrapper Legended or with the ChartLegends option, the legends you create inherit the styling chosen for your chart.

You can use ChartLegends to create legends for your charts.

The labels match the data elements:

In[20]:=
Click for copyable input
Out[20]=

To omit a data element from the legend, use None in place of its label:

In[21]:=
Click for copyable input
Out[21]=

Groups of data can also appear in legends:

In[22]:=
Click for copyable input
Out[22]=

Use ChartLabels to create repeating labels for the data elements in each group:

In[23]:=
Click for copyable input
Out[23]=

Use LegendAppearance to change the layout of the labels within the legend, which in this case effectively changes the position of the legend:

In[24]:=
Click for copyable input
Out[24]=

Alternatively, use Placed to put the legend across the bottom of the chart:

In[25]:=
Click for copyable input
Out[25]=

ChartLegends also works with 3D charts:

In[7]:=
Click for copyable input
Out[7]=
    

Any styling that you apply to your charts is reflected in the legend.

Here, images of textures from ExampleData are set up for use as pictorial bars:

In[26]:=
Click for copyable input

Color the textures:

In[27]:=
Click for copyable input
In[28]:=
Click for copyable input
In[29]:=
Click for copyable input
Out[29]=

Create a bar chart with the textured bars. The textures also appear in the legend:

In[30]:=
Click for copyable input
Out[30]=
    

You can also use the symbolic wrapper Legended to create legends for your charts.

By using Legended, you can provide legend entries for specific data elements in your charts:

In[15]:=
Click for copyable input
Out[15]=
In[16]:=
Click for copyable input
Out[16]=

Legended also works with 3D charting functions:

In[4]:=
Click for copyable input
Out[4]=
New to Mathematica? Find your learning path »
Have a question? Ask support »