On Wed, May 6, 2009 at 9:49 AM, Sebastian Pająk <spcon...@gmail.com> wrote:
> Hello
>
> How can I set decade on log x axis to be equal length to decade on log
> y axis (physically)?
>
> If I make:
>
> ax.set_xscale("log")
> ax.set_yscale("log")
> ax.set_aspect(1)
>
> I get it all wrong, the units are equal, not decades!!
>
> I need the same effect as I get in Gnuplot - the square decades:
>
> set logscale yx;
> set size ratio -1;
>
> How can I do it in matplotlib?
>


I'm afraid that this is not directly supported by the matplotlib,
although I think it should.
However, you can do it with some monkey patching (or with some other
similar way).


import math

def get_data_ratio(self):
    xmin,xmax = self.get_xbound()
    ymin,ymax = self.get_ybound()

    if self.get_xscale() == "log" and self.get_yscale() == "log":
        xsize = max(math.fabs(math.log10(xmax)-math.log10(xmin)), 1e-30)
        ysize = max(math.fabs(math.log10(ymax)-math.log10(ymin)), 1e-30)
    else:
        xsize = max(math.fabs(xmax-xmin), 1e-30)
        ysize = max(math.fabs(ymax-ymin), 1e-30)

    return ysize/xsize

from matplotlib.axes import Axes
Axes.get_data_ratio = get_data_ratio


ax = gca()

ax.set_xscale("log")
ax.set_yscale("log")
ax.set_aspect(1.)

ax.set_xlim(1, 100)
ax.set_ylim(1, 1000)



John and others,
How do you think this being a default behavior?

Regards,

-JJ



> ------------------------------------------------------------------------------
> The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
> production scanning environment may not be a perfect world - but thanks to
> Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
> Series Scanner you'll get full speed at 300 dpi even with all image
> processing features enabled. http://p.sf.net/sfu/kodak-com
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to