Skip to content

Instantly share code, notes, and snippets.

@mastbaum
Created November 28, 2012 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mastbaum/4162313 to your computer and use it in GitHub Desktop.
Save mastbaum/4162313 to your computer and use it in GitHub Desktop.
labeling only some plots in matplotlib
'''Example of labeling only some plots in a matplotlib legend.
Tested with matplotlib==1.0.1
'''
from matplotlib import pyplot as plt
plt.figure(1, facecolor='white')
plt.plot([1,2,3,4], [1,2,3,4], label='foo')
plt.plot([1,2,3,4], [2,4,6,8])
plt.plot([1,2,3,4], [3,6,9,12], label='bar')
plt.legend(loc='lower right')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment