Okay I see what's going on now. The output from axis('tight') specifies
the limits of the two axes:

>  (-0.33718689788053952,
>  7.0809248554913298,
>  -0.34782608695652173,
>  7.3043478260869561)

As you can see it's actually setting negative minimum limits for both
axes, which is why the axes are offset from the (0,0) position. The clue
to this behaviour is in the axis function docstring:

> axis('auto') or 'normal' (deprecated) restores default behavior;
> axis limits are automatically scaled to make the data fit
> comfortably within the plot box.

and

> axis('tight') changes x and y axis limits such that all data is
> shown. If all data is already shown, it will move it to the center
> of the figure without modifying (xmax-xmin) or (ymax-ymin). Note
> this is slightly different than in matlab.

Neither of those will necessarily set the xmin and ymin of the axes to
0. It depends on what data you've plotted before calling axis(). I found
that if I call axis('tight') before plotting anything (i.e. before
calling plot or scatter) then the axes xmin and ymin do get set to 0,
but this is because at the time of calling axis('tight') there is no
data to show.

If you call axis('tight') after plotting data then (contrary to the
docstring) it seems to adjust the axes so that all data is shown **and
none of it is too close to the axes**, there is some degree of padding,
although it is tighter than with axis('auto').

I'm not sure about this 'auto' and 'tight' behaviour. To my eye the
corner formed by the x and y axes at the bottom-left signifies (0,0),
unless otherwise stated. The padding applied by 'normal' and 'tight'
breaks this expectation. In my case, when I don't have any numerical
labels on the axes to show that they begin at (-0.34,-0.35), I should
probably make sure that they begin at (0,0).

You can explicitly set the axes limits with axis(xmin=0,ymin=0).



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
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

Reply via email to