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:
| Out[20]= |  |
To omit a data element from the legend, use
None in place of its label:
| Out[21]= |  |
Groups of data can also appear in legends:
| Out[22]= |  |
Use
ChartLabels to create repeating labels for the data elements in each group:
| 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:
| Out[24]= |  |
Alternatively, use
Placed to put the legend across the bottom of the chart:
| Out[25]= |  |
ChartLegends also works with 3D charts:
| 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:
| Out[29]= |  |
Create a bar chart with the textured bars. The textures also appear in the legend:
| 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:
| Out[15]= |  |
| Out[16]= |  |
Legended also works with 3D charting functions:
| Out[4]= |  |