On Friday, August 26, 2011, a.sam <a.sa...@gmail.com> wrote:
>
> I have a problem with changing the ticklabels text. In fact I am aware of
the
> method which is explained by the matplotlib help center. But I need more
> flexibility with ticklabels text.
> For example, I want to add an "a" before every tick label of the xaxis. So
I
> wrote the following sample code:
> #----------------------------------------------------------------
> from pylab import *
> #
> t = arange(0.0, 100.0, 0.1)
> s = sin(0.1*pi*t)*exp(-t*0.01)
> #
> ax = subplot(111)
> plot(t,s)
> #
> for label1 in ax.xaxis.get_majorticklabels():
>    label1.set_weight('bold')
>    label1._text="a"+label1._text
> #
> show()
> #----------------------------------------------------------------
> It seems to me that `` label1._text="a"+label1._text ' '  should do this
> job, but it does nothing. The only way I found was using something like
> this:
>
> ax.xaxis.set_ticklabels(('a0','a20','a40','a60','a80','a100'))
>
> which I would rather not to use, because there are lots of graphs in my
> project and I do not want to this process manually. So, my question is
which
> property or method would set (and also get) the ticklabel text?
>
> Thanks is advance

Why not use get_ticklabels() to get the list of strings, modify that, and
call set_ticklabels() with the modified list?

Ben Root
------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to