I'm a newbie to Matplotlib but a longtime gnuplot user.

Using the matlab module, what is the right way to

set xzeroaxis

(using gnuplot terminology). Using axis and hline seems

cumbersome, so I assume there is a better way to implement

this common need.

Thank you,

Alan Isaac

MATLAB doesn't have anything similar, AFAIK, but the following will

work:

def xzeroaxis(form='k'): # draw a line at y=0 on the current plot

v=axis()

plot(v[0:2],[0,0],form)

def yzeroaxis(form='k'):

v=axis()

plot([0,0],v[2:4],form)

Is this worth adding to the distribution? I doubt it is general enough

to warrant.

John: when I do the following:

v=arange(-5,5)

plot(v,v**3)

xzeroaxis()

yzeroaxis()

the vertical line at x=0 doesn't quite go to top and bottom of the

plot. This is with 0.62.4.

## ···

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 Walton <stephen.walton@...267...>

Dept. of Physics & Astronomy, CSU Northridge

Stephen Walton wrote:

I'm a newbie to Matplotlib but a longtime gnuplot user.

Using the matlab module, what is the right way to

set xzeroaxis

MATLAB doesn't have anything similar, AFAIK, but the following will

work:

def xzeroaxis(form='k'): # draw a line at y=0 on the current plot

v=axis()

plot(v[0:2],[0,0],form)

[...]

I've accomplished this feature via:

ax = axis()

set(gca(). hlines([0.], ax[0], ax[1])[0], linewidth=1)

I don't remember why I did it this way instead of just plotting. Maybe I thought is was more clever.

Does this method avoid auto-scaling?

-g

## ···

On Mon, 2004-09-06 at 06:28, Alan G Isaac wrote: