marcusantonius wrote: > Hello, > > I have the problem, that sometimes the first and last ticklabel of a > colorbar is not drawn. E.g. if I create a colorbar through > fig.colorbar(p3,orientation='horizontal',ticks=np.arange(0.0,8,2)) > I only get ticklabels at 2,4,6, but I would like it to have 0,2,4,6,8 and I > don't know how to control this behaviour. If I do > cb=fig.colorbar(p3,orientation='horizontal',ticks=np.arange(0.0,8,2)) > cb.ax.xaxis.set_ticks(np.arange(0,8,2)) > the colorbar vanishes and instead I have 4 ticks with the labels > 0.8,1.6,2.4,3.2 > > Thank you for your help, > Markus > >
Markus, The problem here is not the specification of the ticks, it is the actual range of the colorbar, which is taken from the norm object used in the color mapping. Try this (in ipython -pylab): imshow(rand(10,10)*8, vmin=0, vmax=8) colorbar(ticks=[0,2,4,6,8]) Alternatively, you can use the set_clim() method on any Mappable such as an image, or the pyplot clim() function, to set the limits. Note also that to get the sequence [0,2,4,6,8] you need arange(0,9,2), not arange(0,8,2). Or you can use linspace(0,8,5) if you prefer. Eric ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://www.creativitycat.com _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users