[Matplotlib-users] changing labeling of axes

Thomas Caswell tcaswell at gmail.com
Wed Nov 8 12:01:06 EST 2017


You can do this with the formatter on the axis, see
https://matplotlib.org/gallery/ticks_and_spines/tick-formatters.html#sphx-glr-gallery-ticks-and-spines-tick-formatters-py
 and https://matplotlib.org/api/ticker_api.html

You can also pass log-spaced bins to `hist2D` and then set the axis scales
to log (but trying to construct an example did not got as I expected...)

Tom

On Wed, Nov 8, 2017 at 10:10 AM Slavin, Jonathan <jslavin at cfa.harvard.edu>
wrote:

> Hi,
>
> I'm wondering if anyone knows of a good way to relabel axes for a
> particular case I'm dealing with. I'm making a 2D histogram, using hist2d
> of course.  The thing is that for my case, where I'm plotting the density
> vs. pressure for results from a hydro run, it makes more sense to use the
> log of the quantities as the inputs for hist2d.  So then I need to give the
> log of the density and pressure to hist2d. This works fine for making the
> histogram, but then the axes are labelled with log10(n), log10(P).  I'd
> prefer to have the axes labelled as for a logarithmic plot, so instead of
> say 4.0, 10^4.  Is there a simple way of doing that. I'm pretty sure I can
> just specify by hand the ticks and tick labels, though that's kind of a
> pain. Any help would be appreciated.
>
> Regards,
> Jon
>
> --
> ________________________________________________________
> Jonathan D. Slavin                 Harvard-Smithsonian CfA
> jslavin at cfa.harvard.edu       60 Garden Street, MS 83
> phone: (617) 496-7981       Cambridge, MA 02138-1516
> cell: (781) 363-0035             USA
> ________________________________________________________
>
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20171108/93aa6021/attachment.html>


More information about the Matplotlib-users mailing list