mouse coordinate precision in figures

Hello,

When you make a figure and move the mouse around inside the axes, the
x- and y-values appear in the status bar. Is there a way to change the
precision of this data? It's only tracking 3 significant figures and I
need more (say you're zoomed in on some data with a large offset).

Is there a way to change this in matplotlibrc or some global
preference? If not, is it a figure property?

Thanks in advance,
Jack

Hi Jack,

In \matplotlib\axes.py, Axes.format_xdata()

func = self.xaxis.get_major_formatter().format_data_short
->func = self.xaxis.get_major_formatter().format_data

same for Axes.format_ydata()

-Yongtao

···

On Dec 22, 2007 1:46 PM, Jack Sankey <jack.sankey@…287…> wrote:

Hello,

When you make a figure and move the mouse around inside the axes, the
x- and y-values appear in the status bar. Is there a way to change the

precision of this data? It’s only tracking 3 significant figures and I
need more (say you’re zoomed in on some data with a large offset).

Is there a way to change this in matplotlibrc or some global

preference? If not, is it a figure property?

Thanks in advance,
Jack


This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft® Visual Studio 2005.

http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

You can also set a custom formatter for each axis without hacking the matplotlib code::

   def custom_formatter(value):
     return str(value)

   gca().fmt_xdata = custom_formatter
   gca().fmt_ydata = custom_formatter

We may want to add a cleaner (more obvious) API for this -- but there might be good reasons that it works this way that I just don't know about.

Cheers,
Mike

Yongtao Cui wrote:

···

Hi Jack,
In \matplotlib\axes.py, Axes.format_xdata()
func = self.xaxis.get_major_formatter().format_data_short
->func = self.xaxis.get_major_formatter().format_data
same for Axes.format_ydata()
-Yongtao

On Dec 22, 2007 1:46 PM, Jack Sankey <jack.sankey@…287… > <mailto:jack.sankey@…287…>> wrote:

    Hello,

    When you make a figure and move the mouse around inside the axes, the
    x- and y-values appear in the status bar. Is there a way to change the
    precision of this data? It's only tracking 3 significant figures and I
    need more (say you're zoomed in on some data with a large offset).

    Is there a way to change this in matplotlibrc or some global
    preference? If not, is it a figure property?

    Thanks in advance,
    Jack

    -------------------------------------------------------------------------
    This SF.net email is sponsored by: Microsoft
    Defy all challenges. Microsoft(R) Visual Studio 2005.
    http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
    _______________________________________________
    Matplotlib-users mailing list
    Matplotlib-users@lists.sourceforge.net
    <mailto:Matplotlib-users@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/matplotlib-users
    <https://lists.sourceforge.net/lists/listinfo/matplotlib-users>

------------------------------------------------------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

There is no particularly good reason and it is not terribly consistent
with the rest of the API, which tends to use function calls more than
attribute settings. It works well enough and there is plenty of code
(mine for example) that utilizes it. The major problem is that it is
not easy for users to find.

JDH

···

On Jan 4, 2008 7:32 AM, Michael Droettboom <mdroe@...86...> wrote:

You can also set a custom formatter for each axis without hacking the
matplotlib code::

   def custom_formatter(value):
     return str(value)

   gca().fmt_xdata = custom_formatter
   gca().fmt_ydata = custom_formatter

We may want to add a cleaner (more obvious) API for this -- but there
might be good reasons that it works this way that I just don't know about.

Thanks guys! You can also just skip a step and go:

gca().fmt_xdata = str
gca().fmt_ydata = str

:slight_smile:

I changed it in Axes.py. It would be cool if there was something in
matplotlibrc, but now that I understand how it works, it's no biggy to
me.

Take care,
Jack

···

On Jan 4, 2008 9:18 AM, John Hunter <jdh2358@...287...> wrote:

On Jan 4, 2008 7:32 AM, Michael Droettboom <mdroe@...86...> wrote:
> You can also set a custom formatter for each axis without hacking the
> matplotlib code::
>
> def custom_formatter(value):
> return str(value)
>
> gca().fmt_xdata = custom_formatter
> gca().fmt_ydata = custom_formatter
>
> We may want to add a cleaner (more obvious) API for this -- but there
> might be good reasons that it works this way that I just don't know about.

There is no particularly good reason and it is not terribly consistent
with the rest of the API, which tends to use function calls more than
attribute settings. It works well enough and there is plenty of code
(mine for example) that utilizes it. The major problem is that it is
not easy for users to find.

JDH