# ymax

Hi Kamel,

(I’m recopying to the list; unfortunately, the mailing list doesn’t do this automatically)

Well, this is strange: I swear I tested this yesterday, and I got (-1.94, 1.94) when calling `get_ylim` before `show`. But when I test this today, I get (-1, 1) with the call before `show`.

I guess the initial call to `get_ylim` returns that data limits (which are (-1, 1) in this case), but the call to `axis('equal')` results in a rescaling at draw time.

If you’re just trying to readjust the plot before the plot blocks execution, you can run `draw()` right before calling `get_ylim`. There may be a better approach, though.

-Tony

···

On Thu, Jun 7, 2012 at 12:14 PM, kamel maths <kamel.maths@…1896…> wrote:

It is not very clear for me yet. This a script I tested.

from pylab import *

fig = figure()

ax.axis(‘equal’)

x = linspace(-2, 3, 50)

ax.plot(x, sin(x))

ylim = ax.get_ylim()

print(ylim)

show()

ylim = ax.get_ylim()

print(ylim)

With the first print, I obtain (-1,1) and with the second one, after having closed the figure showed, I obtain (-1.94,1.94). But I would like to obtain (-1.94,1.94) with the first one in order to use this data in the figure.

Is it possible ?

Thank you very much. It works at last.

Kamel

2012/6/7 Tony Yu <tsyu80@…287…>

···

On Thu, Jun 7, 2012 at 12:14 PM, kamel maths <kamel.maths@…287…> wrote:

It is not very clear for me yet. This a script I tested.

from pylab import *

fig = figure()

ax.axis(‘equal’)

x = linspace(-2, 3, 50)

ax.plot(x, sin(x))

ylim = ax.get_ylim()

print(ylim)

show()

ylim = ax.get_ylim()

print(ylim)

With the first print, I obtain (-1,1) and with the second one, after having closed the figure showed, I obtain (-1.94,1.94). But I would like to obtain (-1.94,1.94) with the first one in order to use this data in the figure.

Is it possible ?

Hi Kamel,

(I’m recopying to the list; unfortunately, the mailing list doesn’t do this automatically)

Well, this is strange: I swear I tested this yesterday, and I got (-1.94, 1.94) when calling `get_ylim` before `show`. But when I test this today, I get (-1, 1) with the call before `show`.

I guess the initial call to `get_ylim` returns that data limits (which are (-1, 1) in this case), but the call to `axis('equal')` results in a rescaling at draw time.

If you’re just trying to readjust the plot before the plot blocks execution, you can run `draw()` right before calling `get_ylim`. There may be a better approach, though.

-Tony