|
From: John H. <jdh...@ac...> - 2004-09-07 03:10:05
|
>>>>> "Stephen" == Stephen Walton <ste...@cs...> writes:
Stephen> On Mon, 2004-09-06 at 06:28, Alan G Isaac wrote:
>> I'm a newbie to Matplotlib but a longtime gnuplot user. Using
>> the matlab module, what is the right way to set xzeroaxis
Stephen> MATLAB doesn't have anything similar, AFAIK, but the
Stephen> following will work:
Stephen> def xzeroaxis(form='k'): # draw a line at y=0 on the
Stephen> current plot v=axis() plot(v[0:2],[0,0],form)
Stephen> def yzeroaxis(form='k'): v=axis() plot([0,0],v[2:4],form)
Stephen> Is this worth adding to the distribution? I doubt it is
Stephen> general enough to warrant.
Stephen> John: when I do the following: v=arange(-5,5)
Stephen> plot(v,v**3) xzeroaxis() yzeroaxis()
Stephen> the vertical line at x=0 doesn't quite go to top and
Stephen> bottom of the plot. This is with 0.62.4.
Without testing, my guess is that the autoscale magic is getting in
your way. Every plot command calls autoscale, which in the absence of
bugs will include the data but may exceed it. Ie, if you plot data
with a x range from 0.1 to 9.9, it may set the xlim from 0--10.
Thus, although your idea of using the axis return values to get the
min, max is nice, it fails when the autoscale chooses a wider range
for nice ticking. The solution I posted a few minutes ago in which
the span is plotted in *axes* coordinates rather than data coordinates
circumvents this problem.
Cheers!
JDH
|