compresson ratio

So this is almost a feature request. The only problem is

    > that gnuplot's size command does not seem obviously suited
    > to the matplotlib.matlab model, and I'm not sure what a good
    > version would be. I think it would be something like "get
    > the current axis, keep the "long" axis (as implied by the
    > ratio) full length, and "shrink" the shorter axis as
    > necessary to achieve the right ratio. This would respect
    > the existing margins to everywhere except by the shrinking
    > axis. However it would probably be better to adjust the
    > figure size as well, to keep the margins unchanged.

I'm not fully understanding you, in part because I find the
terminology ambiguous. Could you give an example of what you want to
achieve (eg a scatterplot with a square viewing window). For
concreteness, we have

    ylim / xlim : the data view limits
    axh / axw : the axes height / width, relative coords 0-1
    figh / figw : the figure width and height in inches
    dpiy / dpix : the display devices resolution in pixels in the
                    vertical and horizontal directions

In order to get true physical sizes and ratios, we need to know dpiy
and dpix. matplotlib currently only supports a single dpi, though it
is still possible to hack true sizes by adjusting for example, figh
and figw to compensate for variation in dpiy and dpix.

It is certainly possible to provide some helper functions to create a
properly sized and scaled figure and axes with a desired aspect ratio
or physical size.

JDH

John Hunter wrote:

I'm not fully understanding you, in part because I find the
terminology ambiguous.

I'm not sure what he means either, but it sounds like what he wants is to be able to specify the ratio of the x-scale and y-scale of the figure. Most commonly, you'd want to specify they are the same, like MATLAB's

axis('equal')

Even if the OP wasn't looking for that, I am. Can matplotlib do that?

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

Alan G Isaac <aisaac@...310...> writes:

So this is almost a feature request. The only problem is
that gnuplot's size command does not seem obviously suited
to the matplotlib.matlab model, and I'm not sure what a good
version would be. I think it would be something like "get
the current axis, keep the "long" axis (as implied by the
ratio) full length, and "shrink" the shorter axis as
necessary to achieve the right ratio. This would respect
the existing margins to everywhere except by the shrinking
axis. However it would probably be better to adjust the
figure size as well, to keep the margins unchanged.

I'm not fully understanding you, in part because I find the
terminology ambiguous. Could you give an example of what you want to
achieve (eg a scatterplot with a square viewing window). For
concreteness, we have
    ylim / xlim : the data view limits
    axh / axw : the axes height / width, relative coords 0-1
    figh / figw : the figure width and height in inches
    dpiy / dpix : the display devices resolution in pixels in the
                    vertical and horizontal directions
In order to get true physical sizes and ratios, we need to know dpiy
and dpix. matplotlib currently only supports a single dpi, though it
is still possible to hack true sizes by adjusting for example, figh
and figw to compensate for variation in dpiy and dpix.

In gnuplot if I want to set a compression ratio
of unity for a figure that has an xrange of [xmin,xmax]
and a yrange of [ymin,ymax], I just say
set size ratio (ymax-ymin)/(xmax-xmin)
So e.g. if I do this when I am plotting a function f:R->R
then the unit size will be physically identical along
each axis. So for example if I plot a circle it looks
like a circle and not an oval.

In a very clever move, gnuplot also allows
set size ratio -1
to achieve the same effect.

Crudely: I'm looking for something just as simple in
matplotlib.matlab. My last post outlined what I
think the current procedure is to achieve the same
effect, and it is much more cumbersome. While this
matters little when one is leisurely writing a script,
it matters a lot when one is doing interactive plotting
in a classroom setting.

Now you point out that this request has an ambiguity:
what "physical" medium am I talking about? Specifically,
a true compression ratio on screen requires tricky stuff
if dpiy != dpix. OK, I assume ignoring this will yield
a "close enough" result in a classroom setting, so the
only time I need it to be exact is when I produce figures
for paper display.

Hope that is clearer.

Thank you,
Alan Isaac

···

On Mon, 13 Sep 2004, John Hunter apparently wrote:

This seems the same in the 2D case.
I haven't thought about what it means in the 3D case.

Cheers,
Alan Isaac

···

On Mon, 13 Sep 2004, Chris Barker apparently wrote:

I'm not sure what he means either, but it sounds like what he wants is
to be able to specify the ratio of the x-scale and y-scale of the
figure. Most commonly, you'd want to specify they are the same, like
MATLAB's
axis('equal')