displaying a colored 2d array in matplotlib in Python
Posted
by user248237
on Stack Overflow
See other posts from Stack Overflow
or by user248237
Published on 2010-06-13T23:51:16Z
Indexed on
2010/06/13
23:52 UTC
Read the original article
Hit count: 207
I'd like to plot a 2-d matrix from numpy as a colored matrix in Matplotlib. I have the following 9-by-9 array:
my_array = diag(ones(9))
# plot the array
pcolor(my_array)
I'd like to set the first three elements of the diagonal to be a certain color, the next three to be a different color, and the last three a different color. I'd like to specify the color by a hex code string, like "#FF8C00". How can I do this?
Also, how can I set the color of 0-valued elements for pcolor?
© Stack Overflow or respective owner