set_ylim() does not work with twinx()-axes

Hi, I am plotting two graphs in one according to

    > http://matplotlib.sourceforge.net/examples/two_scales.py

    > I want the plot belonging to the right axis to start with
    > y=0. However,

    > ax2.set_ylim(ymin=0.0)

    > does not affect the plot at all.

It always helps to post a complete example; otherwise we have to use
our amazing powers of deduction to figure out what you might be doing
wrong. In this case, two possibilities come to mind:

  1) you are calling set_ylim before a plot command and the autoscaler
     is kicking on the plot command and overriding your changes. You
     should call set_ylim after all plot commands, or turn autoscaling
     off with the autoscale_on property of the Axes

  2) you are working in interactive mode, eg ipython -pylab, and the
     draw command is not being triggered since you are making an OO
     call. You can force a draw command in pylab with "draw" or with
     fig.canvas.draw().

The following *does* work for me, so maybe you can follow it as an
example

from pylab import *

ax1 = subplot(111)
t = arange(0.01, 10.0, 0.01)
s1 = exp(t)
plot(t, s1, 'b-')
xlabel('time (s)')
ylabel('exp')

# turn off the 2nd axes rectangle with frameon kwarg
ax2 = twinx()
s2 = sin(2*pi*t)
plot(t, s2, 'r.')
ylabel('sin')
ax2.yaxis.tick_right()
ax2.set_ylim(ymin=-3)
show()

Hi,

this example does not work for me: Right axis is in the range [-1, 1].
(The same as the example two_axes.py with an additional set_ylim in my
previous mail. Sorry for the sparse information.)

matplotlib.__version__ == 0.82
python 2.4

Thanks,
wr

···

Am Freitag, 20. Oktober 2006 17:31 schrieb John Hunter:

from pylab import *

ax1 = subplot(111)
t = arange(0.01, 10.0, 0.01)
s1 = exp(t)
plot(t, s1, 'b-')
xlabel('time (s)')
ylabel('exp')

# turn off the 2nd axes rectangle with frameon kwarg
ax2 = twinx()
s2 = sin(2*pi*t)
plot(t, s2, 'r.')
ylabel('sin')
ax2.yaxis.tick_right()
ax2.set_ylim(ymin=-3)
show()

Willi Richert wrote:

···

Am Freitag, 20. Oktober 2006 17:31 schrieb John Hunter:

from pylab import *

ax1 = subplot(111)
t = arange(0.01, 10.0, 0.01)
s1 = exp(t)
plot(t, s1, 'b-')
xlabel('time (s)')
ylabel('exp')

# turn off the 2nd axes rectangle with frameon kwarg
ax2 = twinx()
s2 = sin(2*pi*t)
plot(t, s2, 'r.')
ylabel('sin')
ax2.yaxis.tick_right()
ax2.set_ylim(ymin=-3)
show()

Hi,

this example does not work for me: Right axis is in the range [-1, 1].
(The same as the example two_axes.py with an additional set_ylim in my previous mail. Sorry for the sparse information.)

matplotlib.__version__ == 0.82

There is the problem: you need to update your matplotlib.

Eric

Thanks. Unfortunately, I've not yet found a more recent ubuntu/dapper repo for
matplotlib. Any experience with installing the ubuntu edgy version (0.87) on
dapper?

Thanks,
wr

···

Am Samstag, 21. Oktober 2006 20:30 schrieb Eric Firing:

>
> matplotlib.__version__ == 0.82

There is the problem: you need to update your matplotlib.

Eric

Willi Richert schrieb:

···

Am Samstag, 21. Oktober 2006 20:30 schrieb Eric Firing:

matplotlib.__version__ == 0.82

There is the problem: you need to update your matplotlib.

Eric

Thanks. Unfortunately, I've not yet found a more recent ubuntu/dapper repo for
matplotlib. Any experience with installing the ubuntu edgy version (0.87) on
dapper?

check out the ubuntu (dapper) section at
http://new.scipy.org/Installing_SciPy/Linux, that repository (by Andrew
Straw) also gives you recent matplotlib packages.
-sven

Hi,

unfortunately, debs.astraw.com is not accessible.

wr@[ikarus]:~> ping debs.astraw.com
ping: unknown host debs.astraw.com

wr@[ikarus]:~> ping www.astraw.com
PING www.astraw.com (66.33.203.253) 56(84) bytes of data.
64 bytes from basic-emu.glass.dreamhost.com (66.33.203.253): icmp_seq=1 ttl=41
time=169 ms

···

Am Montag, 23. Oktober 2006 13:18 schrieb Sven Schreiber:

Willi Richert schrieb:
> Am Samstag, 21. Oktober 2006 20:30 schrieb Eric Firing:
>>> matplotlib.__version__ == 0.82
>>
>> There is the problem: you need to update your matplotlib.
>>
>> Eric
>
> Thanks. Unfortunately, I've not yet found a more recent ubuntu/dapper
> repo for matplotlib. Any experience with installing the ubuntu edgy
> version (0.87) on dapper?

check out the ubuntu (dapper) section at
http://new.scipy.org/Installing_SciPy/Linux, that repository (by Andrew
Straw) also gives you recent matplotlib packages.
-sven

With Linux it is easy to install matplotlib from the tarball or from svn--no need to hunt around for a package.

Eric

Willi Richert wrote:

···

Am Samstag, 21. Oktober 2006 20:30 schrieb Eric Firing:

matplotlib.__version__ == 0.82

There is the problem: you need to update your matplotlib.

Eric

Thanks. Unfortunately, I've not yet found a more recent ubuntu/dapper repo for matplotlib. Any experience with installing the ubuntu edgy version (0.87) on dapper?

Thanks,
wr

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Hi,

even with the newest version the problem remains, unless I put the set_ylim()
command _after_ plot(). Why?

···

Am Samstag, 21. Oktober 2006 20:30 schrieb Eric Firing:

Willi Richert wrote:
> Am Freitag, 20. Oktober 2006 17:31 schrieb John Hunter:
>> from pylab import *
>>
>> ax1 = subplot(111)
>> t = arange(0.01, 10.0, 0.01)
>> s1 = exp(t)
>> plot(t, s1, 'b-')
>> xlabel('time (s)')
>> ylabel('exp')
>>
>>
>> # turn off the 2nd axes rectangle with frameon kwarg
>> ax2 = twinx()
>> s2 = sin(2*pi*t)
>> plot(t, s2, 'r.')
>> ylabel('sin')
>> ax2.yaxis.tick_right()
>> ax2.set_ylim(ymin=-3)
>> show()
>
> Hi,
>
> this example does not work for me: Right axis is in the range [-1, 1].
> (The same as the example two_axes.py with an additional set_ylim in my
> previous mail. Sorry for the sparse information.)
>
> matplotlib.__version__ == 0.82

There is the problem: you need to update your matplotlib.

Eric

wr