question about example of override the default reporting of coords

I looked at the example of overriding the default reporting of coords, which is here:
http://matplotlib.sourceforge.net/examples/pylab_examples/coords_report.html

from pylab import *

def millions(x):
return ‘$%1.1fM’ % (x*1e-6)

x = rand(20)
y = 1e7*rand(20)

ax = subplot(111)
ax.fmt_ydata = millions
plot(x, y, ‘o’)

show()

I don’t understand what the millions function does (with a $ and M ?).
In fact, I get the exact same result when I delete the line

ax.fmt_ydata = millions

Any thoughts?

Hi Mark,

It’s a bit confusing, but there’s actually two different types of formatters. You’re most likely looking for major/minor tick formatters (example). In the above example, the cursor coordinate is reformatted. In an interactive window, you should see the current cursor position in the lower left (this may depend on the backend)—that’s the value that should be reformatted by the millions function.

Best,

-Tony

···

On Thu, May 31, 2012 at 9:31 AM, Mark Bakker <markbak@…287…> wrote:

I looked at the example of overriding the default reporting of coords, which is here:
http://matplotlib.sourceforge.net/examples/pylab_examples/coords_report.html

from pylab import *

def millions(x):
return ‘$%1.1fM’ % (x*1e-6)

x = rand(20)
y = 1e7*rand(20)

ax = subplot(111)
ax.fmt_ydata = millions
plot(x, y, ‘o’)

show()

I don’t understand what the millions function does (with a $ and M ?).
In fact, I get the exact same result when I delete the line

ax.fmt_ydata = millions

Any thoughts?

OK. Got it. That is not what I was looking for.

But, why the leading $ sign? Just as an example? The $ sign shows up in the cursor coordinate now. Is that what was supposed to happen (it is confusing with the $ sign also being used for mathtext formatting, as you know).

Thanks,

Mark

···

On Thu, May 31, 2012 at 3:49 PM, Tony Yu <tsyu80@…287…> wrote:

On Thu, May 31, 2012 at 9:31 AM, Mark Bakker <markbak@…287…> wrote:

I looked at the example of overriding the default reporting of coords, which is here:
http://matplotlib.sourceforge.net/examples/pylab_examples/coords_report.html

from pylab import *

def millions(x):
return ‘$%1.1fM’ % (x*1e-6)

x = rand(20)
y = 1e7*rand(20)

ax = subplot(111)
ax.fmt_ydata = millions
plot(x, y, ‘o’)

show()

I don’t understand what the millions function does (with a $ and M ?).
In fact, I get the exact same result when I delete the line

ax.fmt_ydata = millions

Any thoughts?

Hi Mark,

It’s a bit confusing, but there’s actually two different types of formatters. You’re most likely looking for major/minor tick formatters (example). In the above example, the cursor coordinate is reformatted. In an interactive window, you should see the current cursor position in the lower left (this may depend on the backend)—that’s the value that should be reformatted by the millions function.

Best,

-Tony

I’m guessing that the example was displaying millions of dollars along the y-axis. The dollar sign can be confusing, but it’s nice to know that the mathtext parser doesn’t get confused :wink:

-Tony

···

On Thu, May 31, 2012 at 10:03 AM, Mark Bakker <markbak@…287…> wrote:

OK. Got it. That is not what I was looking for.

But, why the leading $ sign? Just as an example? The $ sign shows up in the cursor coordinate now. Is that what was supposed to happen (it is confusing with the $ sign also being used for mathtext formatting, as you know).

Thanks,

Mark

The mathtext parser doesn’t kick in unless there is a pair of
dollar signs.

Mike
···

On 05/31/2012 10:12 AM, Tony Yu wrote:

    On Thu, May 31, 2012 at 10:03 AM, Mark > Bakker <markbak@...287...> >         wrote:

OK. Got it. That is not what I was looking for.

      But, why the leading $ sign? Just as an example? The $ sign

shows up in the cursor coordinate now. Is that what was
supposed to happen (it is confusing with the $ sign also being
used for mathtext formatting, as you know).

      Thanks,



      Mark
      I'm guessing that the example was displaying millions of

dollars along the y-axis. The dollar sign can be confusing,
but it’s nice to know that the mathtext parser doesn’t get
confused :wink: