Hi,

On Fri, 2011-08-26 at 06:09 -0700, a.sam 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.

You could set the formatter yourself instead of manipulating strings or
setting the ticklabels by hand. IE:

my_formatter = matplotlib.ticker.FormatStrFormatter('a%s')
#etc... see http://matplotlib.sourceforge.net/api/ticker_api.html

a = plt.gca()
a.xaxis.set_major_formatter(my_formatter)

plt.draw()

Regards,

Sebastian


> 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



------------------------------------------------------------------------------
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