Issue
I have a matrix M whose values are between 0 and 10. I would like to plot it using the color scheme:
plt.pcolormesh((M), shading='auto', cmap='twilight')
plt.colorbar()
but plotting in different colors (eg. red and black) all the values that higher than 8 (resp. lower than 2) How can I use pcolormesh to do so?
Solution
I found a solution:
my_cmap = plt.get_cmap(name='viridis', lut=None).copy()
my_cmap.set_under('k')
my_cmap.set_over('y')
plt.pcolormesh((M), shading='auto',cmap=my_cmap,vmin=2,vmax=8)
plt.colorbar(extend = 'both')
Answered By - Francis1984
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.