[Matplotlib-users] question about example of override the default reporting of coords From: Mark Bakker - 2012-05-31 13:32:03 Attachments: Message as HTML ```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? ```
 [Matplotlib-users] question about example of override the default reporting of coords From: Mark Bakker - 2012-05-31 13:32:03 Attachments: Message as HTML ```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? ```
 Re: [Matplotlib-users] question about example of override the default reporting of coords From: Tony Yu - 2012-05-31 13:50:39 Attachments: Message as HTML ```On Thu, May 31, 2012 at 9:31 AM, Mark Bakker 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 ```
 Re: [Matplotlib-users] question about example of override the default reporting of coords From: Mark Bakker - 2012-05-31 14:03:31 Attachments: Message as HTML ```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 wrote: > > > On Thu, May 31, 2012 at 9:31 AM, Mark Bakker 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 > > ```
 Re: [Matplotlib-users] question about example of override the default reporting of coords From: Tony Yu - 2012-05-31 14:13:06 Attachments: Message as HTML ```On Thu, May 31, 2012 at 10:03 AM, Mark Bakker 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 ;) -Tony ```
 Re: [Matplotlib-users] question about example of override the default reporting of coords From: Michael Droettboom - 2012-05-31 15:21:48 Attachments: Message as HTML ```On 05/31/2012 10:12 AM, Tony Yu wrote: > > > On Thu, May 31, 2012 at 10:03 AM, Mark Bakker > 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 ;) > The mathtext parser doesn't kick in unless there is a *pair* of dollar signs. Mike ```