|
From: Mario M. <me...@me...> - 2010-01-20 14:17:27
|
On 20.01.2010 14:55, Scott Sinclair wrote:
>> 2010/1/20 Mario Mech<me...@me...>:
>> cb = pyplot.colorbar(format=r"%2.1f")
>> for j in cb.ax.get_yticklabels():
>> j.set_text('bla')
>> pyplot.show()
>>
>> Doesn't do anything.
>
> It looks like cb.ax.get_yticklabels() returns a list of copies of the
> Text objects. Since you are only changing the copies it has no effect
> on your figure.
> You'll need to use cb.ax.set_yticklabels() and pass a list of strings
> to use as tick labels. See
> http://matplotlib.sourceforge.net/examples/pylab_examples/colorbar_tick_labelling_demo.html
> for an example.
>
> Cheers,
> Scott
Ok, something like
cl = cb.ax.get_yticklabels()
cl[0].set_text('bla')
cb.ax.set_yticklabels([elem.get_text() for elem in cl])
would work for the horizontal colorbars and y replaced by x. But
cl = cb.ax.get_yticklabels()
results in a list of Text objects like Text(0,0,''). So my problem is more to get the TickLabels for vertical colorbars.
Cheers
Mario
--
Dr. Mario Mech
Institute for Geophysics and Meteorology
University of Cologne
Zuelpicher Str. 49a
50674 Cologne
Germany
t: +49 (0)221 - 470 - 1776
f: +49 (0)221 - 470 - 5198
e: me...@me...
w: http://www.meteo.uni-koeln.de/~mmech/
|