How To Specify Colorbar Range And Keep It Regardless Of Plotting Values
I typed this up last night then as I was about to submit it I figured it out. Submitting in case anyone else needs it. I am plotting meteorological values for every hour for multip
Solution 1:
The issue was in my contour() and contourf(). Prior I was passing a 10 within the function.
bm.contour(x, y, to_np(energyproduction), 10, colors="black",vmin=0,vmax=10.0)
bm.contourf(x, y, to_np(energyproduction), 10,cmap = get_cmap('jet'),vmin=0,vmax=10.0)
The 10 designation means that there are 10 steps between the min and max value of the plot. So if there are only values of 0-1 you will get .1 increments of plotting contours etc.
Be removing 10 and seeing it to cbarticks, I was able to get the same colorbar values for each plot regardless of the values.
for file in files:
ncfile = Dataset(file)
cbarticks=np.arange(0.0,10.0,0.5)
bm.contour(x, y, to_np(energyproduction), cbarticks, colors="black",vmin=0,vmax=10.0)
bm.contourf(x, y, to_np(energyproduction), cbarticks, cmap = get_cmap('jet'),vmin=0,vmax=10.0)
plt.colorbar(shrink=.62,ticks=cbarticks)
plt.show()
I believe this is the same designation of "levels" within basemap contour.
Post a Comment for "How To Specify Colorbar Range And Keep It Regardless Of Plotting Values"