On Monday 15 February 2010 09:28:10 Nico Schlömer wrote:
> Hi,
> thanks for the suggestion.
>
> > ax.set_xticks((-pi,pi))
> > ax.set_xticklabels(('$-\pi$','$\pi$'))
>
> I guess color bars are a little special in the sense that
>
>    AttributeError: Colorbar instance has no attribute 'set_yticklabels'
>
> The tick positions are given not by set_yticks either, but as an option
>
>    pylab.colorbar(ticks=(-pi,0,pi))
>
> at the instatiation of the bar. It would indeed be very handy if the
> bars acted like axes.

Hi Nico,

nontheless you can use the axes-method to display your preferred labels. The 
colorbar has its axes as attribute 'ax' (see also my small example below):

cb.ax.set_yticklabels((r'$-\pi$', '0', r'$\pi$'))

Kind regards,
Matthias

-----------------------------------
import matplotlib as mpl
mpl.rc('text', usetex=True)
import matplotlib.pyplot as plt
import numpy as np

ax = plt.axes()
plt.imshow(np.reshape(np.pi*np.arange(-2, 3, 0.5), (2, 5)))
cb = plt.colorbar()
cb.set_ticks((-np.pi, 0.0, np.pi))
cb.ax.set_yticklabels((r'$-\pi$', '0', r'$\pi$'))

plt.show()

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to