How to | Make a Legend for My Plots

Per: https://bugs.wolfram.com/show?number=251274

The Wolfram Language provides many options for customizing and annotating plots. Legends can be added to plots and customized with many of the same methods used to customize other Wolfram Language graphics.

Video Database Error (404) : Video does not exist

This is a selection of examples from the complete "How to" screencast. »

First, load the Plot Legends package:

In[1]:=
Click for copyable input

Use the PlotLegend option to generate a plot with legends:

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

Any styling used in the plot is reflected in the legend:

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

The Plot Legends package can also be used to generate color bars for density and contour plots. However, this requires more effort, as well as some knowledge about the results in the plot.

ShowLegend can be used to display legends for graphics produced with DensityPlot:

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

Similarly, ShowLegend can be used with ContourPlot:

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

You can also programmatically customize your legends with options such as LegendPosition, LegendShadow, LegendBackground, LegendBorder, and ShadowBackground. Further information on doing this is presented in the full screencast.

The methods shown here will not work for adding legends to charts in the Wolfram Language. For information on this, see How to: Make a Legend for My Charts.