Hi,

I have problem setting the axis limits when using a twinx plot. I assume it should be possible to set both x-axis limits after a pylab.twinx() call by issuing only one call to pylab.axis.

The attached tries to plot the same figure in two different ways the first way ends up with different x axis limits for the two plots. The second shows my workaround.

/Jörgen


import sys,os,pdb
import numpy
import pylab
from numpy import sin,cos,pi

x=numpy.arange(0,2*pi,0.1)
x=numpy.arange(0,18,0.1)

pylab.figure(1)
pylab.subplot(111)
pylab.plot(x,sin(x)*0.01)
pylab.axis(xmax=20,ymin=-0.02,ymax=0.02)
pylab.twinx()
pylab.plot(x,cos(x)*0.01)
pylab.axis(xmax=20,ymin=-0.02,ymax=0.02)

pylab.figure(2)
ax1=pylab.subplot(111)
pylab.plot(x,sin(x)*0.01)
pylab.axis(ymin=-0.02,ymax=0.02)
ax2=pylab.twinx()
pylab.plot(x,cos(x)*0.01)
ax2.set_xlim(xmax=20)
ax2.set_ylim(ymin=-0.02,ymax=0.02)
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to