From: Friedrich R. <fri...@gm...> - 2010-03-28 23:20:01
|
2010/3/29 Alan G Isaac <ala...@gm...>: > OK, it's obvious one you point it out. > Sorry for the typo in the example. > > Now suppose I want a colorbar labelled at -1, 0, 1 > but the highest value realized is <1. Can I somehow > use ticks=(-1,0,1) anyway, or do I have to tick at > the realized limits and then label "falsely". Here's an > example, hopefully without typos this time. > > x = np.linspace(-5, 5, 101) > y = x > Z = np.sin(x*y[:,None]).clip(-1,1-1E-6) > fig = plt.figure() > ax = fig.add_subplot(1,1,1) > cax = ax.imshow(Z, interpolation='nearest', extent=[-5,5,-5,5]) > cbar = fig.colorbar(cax, ticks=(-1, 0, 1)) > > As you see, the top tick is not labelled. On my machine, it /labels/ the +1.0, so I changed the mismatch to the safe-failing (1 - 0.1) value, in the script attached. Also I fixed your problem, hopefully. Friedrich |