Skip to content

Instantly share code, notes, and snippets.

@saullocastro
Last active June 26, 2017 16:15
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 saullocastro/8c6c8beffd2f275f862a4556fc36454e to your computer and use it in GitHub Desktop.
Save saullocastro/8c6c8beffd2f275f862a4556fc36454e to your computer and use it in GitHub Desktop.
Matplotlib weird behavior with legendHandles[...].set_color
import matplotlib.pyplot as plt
ax = plt.gca()
ax.plot([0, 1], [0, 1], 'k-.', label='label')
ax.plot([0, 1], [1, 0], 'ko', label='label 2')
leg = ax.legend()
leg.legendHandles[0].set_color('red') # Works
leg.legendHandles[1].set_color('yellow') # Doesn't work
# It depends on the line type that you choose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment