HOME/Articles/

matplotlib example customlabels (snippet)

Article Outline

Python matplotlib example 'customlabels'

Modules used in program:

  • import matplotlib.pyplot as plt
  • import matplotlib.patches as mpatches

python customlabels

Python matplotlib example: customlabels

import matplotlib.patches as mpatches
import matplotlib.pyplot as plt

red_patch = mpatches.Patch(color='red', label='The red data')
plt.legend(handles=[red_patch])