Creating a Colormap Legend in Matplotlib
Posted
by Vince
on Stack Overflow
See other posts from Stack Overflow
or by Vince
Published on 2010-03-15T23:47:26Z
Indexed on
2010/03/15
23:49 UTC
Read the original article
Hit count: 452
matplotlib
|python
Hi fellow Stackers!
I am using imshow() in matplotlib like so:
import numpy as np
import matplotlib.pyplot as plt
mat = '''SOME MATRIX'''
plt.imshow(mat, origin="lower", cmap='gray', interpolation='nearest')
plt.show()
How do I add a legend showing the numeric value for the different shades of gray. Sadly, my googling has not uncovered an answer :(
Thank you in advance for the help.
Vince
© Stack Overflow or respective owner