# ymax

Hi,

for this script:

···

from pylab import *

fig = figure()

ax.axis(‘equal’)

x = linspace(-2, 3, 50)

ax.plot(x, sin(x))

show()

If I try to get ymax with ax.get_ylim(), i obtain 1.0 whereas I observe it is 2.0.

How can I obtain 2.0 for ymax ?

Thanks.

Kamel

Hi Kamel,

I’m not seeing the same result: I actually get back (-1.94, 1.94) from `get_ylim`. When do you call `get_ylim`? Do you call it after calling `plot`?

-Tony

···

On Wed, Jun 6, 2012 at 3:32 PM, kamel maths <kamel.maths@…287…> wrote:

Hi,

for this script:

from pylab import *

fig = figure()

ax.axis(‘equal’)

x = linspace(-2, 3, 50)

ax.plot(x, sin(x))

show()

If I try to get ymax with ax.get_ylim(), i obtain 1.0 whereas I observe it is 2.0.

How can I obtain 2.0 for ymax ?

Thanks.

Kamel

Or, more likely, are you calling it after you close the figure? If so, then the axes has already been cleared and you are merely finding the limits for a newly created (but unshown) figure.

Make sure you get the limits after the plotting, but before the show().

Ben Root

···

On Wed, Jun 6, 2012 at 6:12 PM, Tony Yu <tsyu80@…287…> wrote:

On Wed, Jun 6, 2012 at 3:32 PM, kamel maths <kamel.maths@…287…> wrote:

Hi,

for this script:

from pylab import *

fig = figure()

ax.axis(‘equal’)

x = linspace(-2, 3, 50)

ax.plot(x, sin(x))

show()

If I try to get ymax with ax.get_ylim(), i obtain 1.0 whereas I observe it is 2.0.

How can I obtain 2.0 for ymax ?

Thanks.

Kamel

Hi Kamel,

I’m not seeing the same result: I actually get back (-1.94, 1.94) from `get_ylim`. When do you call `get_ylim`? Do you call it after calling `plot`?

-Tony