On Fri, May 29, 2009 at 10:50 AM, Xavier Gnata <xavier.gn...@gmail.com> wrote:

>> I had the same problem and fixed it by changing just two lines of code in 
>> the axes.py (line 1812 and 1814). Just change the formatter in 
>> 'self.xaxis.major.formatter.set_scientific(sb)' to whatever you want (the 
>> same for y).

You don't need to modify the internals of axes.py -- just set the
formatter on the axes instance itself.

  http://matplotlib.sourceforge.net/search.html?q=codex+set_major_formatter

> Indeed, but it should really be fixed in the svn.

We could perhaps be a little smarter about this, but consider that one
can easily plot lines over images

In [30]: imshow(np.random.rand(512,512))
Out[30]: <matplotlib.image.AxesImage object at 0x151c4f4c>

In [31]: plot(np.arange(512), np.arange(512))

Since the plot can be a mix of images, polygons, lines, etc, it is not
obvious that the formatter should be int.  We could trap the case
where you have only an image, no other data, and haven't set the
extent, but it would be complicated because you may add data to the
plot later and we would have to track that we had attempted to be
clever but we should now undo our cleverness.  Our general philosophy
is to make is easy for you to customize when the default behavior
doesn't suit you, so try

  import matplotlib.ticker as ticker
  ax.xaxis.set_major_formatter(ticker.FormatStrFormatter('%d'))
  .. and ditto for yaxis ..

in addition to the ticks, you can customize how the coords appear in
the toolbar by setting

  ax.fmt_xdata = ticker.FormatStrFormatter('%d')
  ... and ditto for fmt_ydata

There are a variety of formatters available

  http://matplotlib.sourceforge.net/api/ticker_api.html

JDH

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to