order of axis('scaled') and plot()

Hello Mark,
Hello everyone,

I wrote myself a little program which juggled five commands in all possible
orders saving each plottingresult in a png. What I could see was that (with
autoscale_on=False) the commands

  imshow(something),
  plot(something)
  axis('scaled')
  axis('equal')
  axis([-2,2,-3,3]))

had to obey two rules. Then and only then the plot looked like I wanted
(i.e. it had the correct limits given by axis([...]) and a circle looked
like a circle).
(i) plot() has to be before axis([-2,2,-3,3])
(ii) imshow() has to be before axis([-2,2,-3,3])

I think (i) everyone knows from everyday experience with MPL. Then (ii)
doesn't suprise too much.

Remark 1)
I put axis('equal') AND axis('scaled') in, just to check out
if everything works fine. It seems to me that axis('scaled') overrules
axis('equal').
In other words: I suppose axis('equal') doesn' set fixLimits=False.
I - preferring axis('scaled') - doesn't find this to bad. But nevertheless
it could be confusing to the user who prefers the other option ... on the
other hand: Propably no-one uses axis('equal') AND axis('scaled') in one
program (except me doing a 120 permutations :wink:

Remark 2)
Still: I can't become a really friend of this. If autoscale_on=True I would
understand (i) and (ii). But it is False. When plotting doesn't autoscale
why are the limits changed? In other words: Why (i) and (ii)? You could
propably say: We already talked about the difference in
  axis('equal')
  axis([-2,2,-3,3])
and
  axis([-2,2,-3,3])
  axis('equal').
But this is not true for axis('scaled'). Here the order doesn't play a role
(At least I saw this in a seperate example and I also couldn't figure out
that the order played a role for 'scaled' in my permutations - notice the
"Then and only then" before (i) and (ii)!)

That's as far as I came right now.
Bye,
Martin

PS: I don't know if this permutation-doing program is of any use to you.
That's why I haven't attached it. If you would like to have it - let me know
... but I wouldn't exhibit it in the Louvre if you know what I mean :wink:

···

--
Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
Satte Provisionen f�r GMX Partner: http://www.gmx.net/de/go/partner

Hello,
I agree that autoscaling combined with e.g. axis('scaled') is really broken...

my worst annoyance is how the figure size is changed when I do
axis('scaled') and use the zoom to rect mode, e.g.

from pylab import *
im=3 ; jm=4
[y,x] = meshgrid(arange(0.5,jm+0.5), arange(0.5,im+0.5))
h = sqrt(x**2 + y**2)
pcolor(x,y,h)
axis([0,im,0,jm])
axis('scaled')
hsv()
show()

then zoom to rect and pick a very "wide" rectangle - figure changes
size, now zooming to a tall rectangle will make the figure size thin
and tall instead. clicking home restores the axis limits, but the
weird figure size remains... (I use cvs matplotlib)

humble suggestion for developers: using the right button to zoom out
to a rectangle is not intuitive - I would much prefer if a single
right click in the figure in this mode just took me back to the
previous axis limits. and if axis('scaled') is on, it should preserve
the figure aspect ratio no matter what happen - window resize, zooming
in/out, whatever...

otherwise, matplotlib is really improving! good job. the only features
I miss are a pcolor and quiver capable of doing 500x500 data as fast
as pygist :slight_smile:

for those hacking on the colorbar: the scipy xplt colorbar is nice. it
may be possible to use some of the scaling algs. from that one. (see
http://www.scipy.org/cvs/viewcvs/map?rmurl=http%3A//scipy.net/cgi-bin/viewcvsx.cgi/scipy1/xplt/colorbar.py%3Frev%3D1.7%26content-type%3Dtext/vnd.viewcvs-markup)

sincerely,
Helge

···

On 9/8/05, Martin Richter <lawn.mower@...380...> wrote:

Remark 2)
Still: I can't become a really friend of this. If autoscale_on=True I would
understand (i) and (ii). But it is False. When plotting doesn't autoscale
why are the limits changed? In other words: Why (i) and (ii)? You could
propably say: We already talked about the difference in

The axis(‘scaled’) was a first quick-and-dirty implementation of
getting the scale of a figure the same along both axes. When it was
implemented in the previous version, John Hunter commented (correctly)
that it didn’t work for subplots. That is what triggered the clean
implementation of axis(‘equal’). I think axis(‘equal’) works correctly.
Except for the known problem that the back button on the toolbar
doesn’t restore the previous position. I will try to fix this in the
next week or so.

I left the axis(‘scaled’) option in, mostly as a novelty, and because I
like it. But it is only useful if you don’t have subplots. Maybe we
should just get rid of it, as it is not really needed anymore. I have no idea what ‘scaled’ and ‘equal’ do together.

Regarding the autoscale_on attribute. I don’t know what that was designed to do. Can anybody explain?

To summarize:

  1. I will add the position to the history so that the backbutton works.
  2. Let’s remove the axis(‘scaled’) option
  3. I don’t know how to keep axes scaled when the window size is changed. Anybody know how to catch such an event?

Mark

···

On 9/8/05, Martin Richter <lawn.mower@…380…> wrote:

Hello Mark,
Hello everyone,

I wrote myself a little program which juggled five commands in all possible
orders saving each plottingresult in a png. What I could see was that (with
autoscale_on=False) the commands

imshow(something),
plot(something)
axis(‘scaled’)
axis(‘equal’)
axis([-2,2,-3,3]))

had to obey two rules. Then and only then the plot looked like I wanted
(i.e. it had the correct limits given by axis([…]) and a circle looked

like a circle).
(i) plot() has to be before axis([-2,2,-3,3])
(ii) imshow() has to be before axis([-2,2,-3,3])

I think (i) everyone knows from everyday experience with MPL. Then (ii)
doesn’t suprise too much.

Remark 1)
I put axis(‘equal’) AND axis(‘scaled’) in, just to check out
if everything works fine. It seems to me that axis(‘scaled’) overrules
axis(‘equal’).
In other words: I suppose axis(‘equal’) doesn’ set fixLimits=False.

I - preferring axis(‘scaled’) - doesn’t find this to bad. But nevertheless
it could be confusing to the user who prefers the other option … on the
other hand: Propably no-one uses axis(‘equal’) AND axis(‘scaled’) in one

program (except me doing a 120 permutations :wink:

Remark 2)
Still: I can’t become a really friend of this. If autoscale_on=True I would
understand (i) and (ii). But it is False. When plotting doesn’t autoscale

why are the limits changed? In other words: Why (i) and (ii)? You could
propably say: We already talked about the difference in
axis(‘equal’)
axis([-2,2,-3,3])
and
axis([-2,2,-3,3])
axis(‘equal’).

But this is not true for axis(‘scaled’). Here the order doesn’t play a role
(At least I saw this in a seperate example and I also couldn’t figure out
that the order played a role for ‘scaled’ in my permutations - notice the

“Then and only then” before (i) and (ii)!)

That’s as far as I came right now.
Bye,
Martin

PS: I don’t know if this permutation-doing program is of any use to you.
That’s why I haven’t attached it. If you would like to have it - let me know

… but I wouldn’t exhibit it in the Louvre if you know what I mean :wink:


Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
Satte Provisionen für GMX Partner:
http://www.gmx.net/de/go/partner

please keep it - as it works now axis('scaled') is similar to the
matlab 'axis image' command, which is very useful. as explained in
matlab:

   AXIS EQUAL sets the aspect ratio so that equal tick mark
       increments on the x-,y- and z-axis are equal in size. This
       makes SPHERE(25) look like a sphere, instead of an ellipsoid.
    AXIS IMAGE is the same as AXIS EQUAL except that the plot
       box fits tightly around the data.

axis image is what you want if you like the grid axes to fit tightly
around an image. when the figure window is resized you want the aspect
ratio and the axis ranges preserved. when zooming in/out you want the
aspect ratio preserved.

Helge

···

On 9/8/05, Mark Bakker <markbak@...287...> wrote:

I left the axis('scaled') option in, mostly as a novelty, and because I
like it. But it is only useful if you don't have subplots. Maybe we should
just get rid of it, as it is not really needed anymore. I have no idea what
'scaled' and 'equal' do together.

The axis('scaled') was a first quick-and-dirty implementation of getting the
scale of a figure the same along both axes. When it was implemented in the
previous version, John Hunter commented (correctly) that it didn't work for
subplots. That is what triggered the clean implementation of axis('equal').
I think axis('equal') works correctly. Except for the known problem that the
back button on the toolbar doesn't restore the previous position. I will try
to fix this in the next week or so.
I left the axis('scaled') option in, mostly as a novelty, and because I like
it. But it is only useful if you don't have subplots. Maybe we should just
get rid of it, as it is not really needed anymore. I have no idea what
'scaled' and 'equal' do together.

Regarding the autoscale_on attribute. I don't know what that was designed to
do. Can anybody explain?

Let me give a try:
There are situations, where the data cover a large range and
one is interested only in a subregion.
Then one can use `axis` to specify the region and
set autoscale_on=False, so that subsequent plots don't change
the limits of the plot

(This is for example to gnuplot's
       set xrange [0.0:10.0]
       set yrange [0.0:10.0]

Gnuplot is more flexible here, as it allows to have autoscaling
on/off on either axis or either limits (uups, another hidden
feature request):
      set xrange [0.0:]
      set yrange [:]

)

To summarize:
1. I will add the position to the history so that the backbutton works.
2. Let's remove the axis('scaled') option

Please don't!!! That seems to be the only option which leads
to the behaviour I need.

I am still confused about all the different options
and differing results, in particular when order is changed.
But if matplotlib wants to be compatable with
the behaviour of matplot wrt. `axis("equal")`, I will
stop complaining and just use `axis("scaled")`.... :wink:

Best,

Arnd

···

On Thu, 8 Sep 2005, Mark Bakker wrote: