numpy - how to set a fixed color bar for pcolor in python matplotlib? -
I am using pcolor with custom color map to plot a matrix of values. I set my color map so that the lower value is white and the higher value is red, as shown below. All of my metrics are priced between 0 and 20 (inclusive) and I should always be as pure and always pure white as always, even if the values of the matrix that do not spread the entire range, for example, if in my matrix There are values between only 2 and 7, so I do not want it to be white as 2 and 7 as red, but color it as the range is still 0 to 20. How can I do this? I tried to use the "Tix =" option of darbar but it was not working
This is my current code (suppose that is the value to be plotted in "my_matrix"): Any ideas How to brief can fix it? Thanks a lot. An estimate: Your stage may be fine when plotted by cdict = {'red': ((0.0, 1.0, 1.0)
cdict = {'red': ((0.0, 1.0, 1.0), (0.0, 1.0, 1.0), (1.0, 0.0, 0.0)), 'blue' (0.5, 1.0, 1.0), (1.0, 1.0, 1.0)), 'green' : (0.0, 1.0, 1.0), (0.5, 1.0, 1.0), (1.0, 0.0, 0.0))} my_cmap = matplotlib.colors.LinearSegmentedColormap ('my_colormap', cdict, 256) colored_matrix = plt.pcolor My_matrix , Cmap = my_cmap) plt.colorbar (colored_matrix, ticks = [0, 5, 10, 15, 20])
vmin
and
pylab.imshow (im, vmin = 0, vmax = 20)
Comments
Post a Comment