SourceForge logo
SourceForge logo
Menu

Re: [Matplotlib-users] Scatterplot problem

From: chombee <ch...@ne...> - 2008年02月28日 15:16:19
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).

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /