Hi to all!

I have a question concerning reformatting of axis-ticks via the
FuncFormatter-class. In german, it's common to use a comma as separator for
decimal numbers instead of a dot. To realize it in matplotlib, I do
something like

from matplotlib.ticker import FuncFormatter
import pylab
pylab.figure()
formatter = FuncFormatter(lambda x,pos: ("%.2f"%x).replace(".",","))
ax = pylab.axes()
ax.xaxis.set_major_formatter(formatter)
ax.yaxis.set_major_formatter(formatter)
ax.plot(pylab.arange(0,1,0.1),pylab.arange(0,1,0.1))

This works fine for me, but I encounter a problem when I do an
imshow-command with a colorbar. In the imshow-axes, it's o.k., but for the
colorbar it doesn't really work. I do

cb = pylab.colorbar()
cb.ax.yaxis.set_major_formatter(formatter)

and, actually, all dots are replaced by com9mata, but the values are also
changed! E.g. instead of the old values (without formatter) from 0-0.54, the
values are increased to 0-0.95. The complete code for this example would be:

from matplotlib.ticker import FuncFormatter, ScalarFormatter
import pylab
pylab.figure()
formatter = FuncFormatter(lambda x,pos: ("%.2f"%x).replace(".",","))
ax = pylab.axes()
ax.xaxis.set_major_formatter(formatter)
ax.yaxis.set_major_formatter(formatter)
data = pylab.zeros((100,100),"d")
data[10,10] = 0.567
pylab.imshow(data)
cb = pylab.colorbar()
cb.ax.yaxis.set_major_formatter(formatter)

Can anyone explain why it doesn't work out as I expect it to work? Or is
there a better, more standard way to substitute the dots by commata?

Thanks,
Thorsten
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to