Python/Matplotlib - Colorbar Range and Display Values -
when using matplotlib contour plot, i'm having trouble getting colorbar display want. i've read through numerous similar examples, have still not been able want.
in image below, want 2 things changed. want minimum value , maximum values display on color bar (the max should 2.0 , min -0.1). these 2 values should @ edge of colorbar. also, want colorbar display value @ every color transition. example. in plot below, between 2.1 , 1.8, there color transition value isn't displayed.
can please me? think may need use norm, hasn't worked me far.
thanks,
code:
import numpy np import matplotlib.pyplot plt xi = np.array([0., 0.5, 1.0]) yi = np.array([0., 0.5, 1.0]) zi = np.array([[0., 1.0, 2.0], [0., 1.0, 2.0], [-0.1, 1.0, 2.0]]) plt.contour(xi, yi, zi, 15, linewidths=0.5, colors='k') plt.contourf(xi, yi, zi, 15, cmap=plt.cm.jet) plt.colorbar() plt.show()
if understand correctly want, think should it:
import numpy np import matplotlib.pyplot plt xi = np.array([0., 0.5, 1.0]) yi = np.array([0., 0.5, 1.0]) zi = np.array([[0., 1.0, 2.0], [0., 1.0, 2.0], [-0.1, 1.0, 2.0]]) v = np.linspace(-.1, 2.0, 15, endpoint=true) plt.contour(xi, yi, zi, v, linewidths=0.5, colors='k') plt.contourf(xi, yi, zi, v, cmap=plt.cm.jet) x = plt.colorbar(ticks=v) print x plt.show()
Comments
Post a Comment