Hi Eric, thank you so much for pointing this out! Didn't know about the function before, it really helps me a lot!
However, for the current problem it doesn't help. The scaling of the second axis broken without any margin or padding changes. As a workaround, I could of course plot the data two times, first in the first axis, and then in the second axis, and make sure the margins are equal. However, this would considerable increase the file size for vector based formats as I plot *a lot* of data points :) Either way, thanks a lot for this hint! 2011/3/11 Eric Firing <efir...@hawaii.edu>: > On 03/10/2011 01:13 AM, Daniel Mader wrote: >> Maybe I should mention that there are actually two reasons why I don't >> like this behavior: >> >> 1) it's sometimes very hard to read what's going on, >> 2) there also seems to be a bug when the limits are changed later, see >> attached results: the upper subplot is default, the lower subplot uses >> the padding. >> >> ##-------------------------- >> def update_ax2(ax1): >> ''' >> Automatically update ylim of ax2 when ylim of ax1 changes. >> ''' >> y1, y2 = ax1.get_ylim() >> ## modify the limits >> ax2.set_ylim((Tc(y1), Tc(y2))) >> ax2.figure.canvas.draw() >> >> Both plots are actually identical but use a different x-axis. In >> ordert to create a nicely padded plot, I use the following function, >> which breaks the scaling information AND the calculation of the second >> axis limits: >> >> ##-------------------------- >> def axispaddingAX(ax): >> ''' >> Saubere bzw. schoene Achsenskalierung für MPL-Skripten. >> ''' >> lines = ax.get_lines() >> xtemp = [] >> ytemp = [] >> for line in lines: >> xtemp.append(min(line.get_xdata())) >> xtemp.append(max(line.get_xdata())) >> ytemp.append(min(line.get_ydata())) >> ytemp.append(max(line.get_ydata())) >> xmin,xmax = min(xtemp),max(xtemp) >> ymin,ymax = min(ytemp),max(ytemp) >> span = 0.05 >> rangex = (xmin-span*(xmax-xmin), xmax+span*(xmax-xmin)) >> rangey = (ymin-span*(ymax-ymin), ymax+span*(ymax-ymin)) >> ax.set_xlim(rangex) >> ax.set_ylim(rangey) > > I don't know if it would help overall, but in place of your padding > function, have you considered the pylab or pyplot margins() function? > > Eric > >> >> >> Thanks a lot in advance for any hint or comment on this, >> Daniel >> >> 2011/3/10 Daniel Mader<danielstefanma...@googlemail.com>: >>> Hi, >>> >>> is it possible to change the default y-axis scaling so that the >>> ticks/label are not with respect to the large offset? >>> >>> For example: >>> >>> import scipy >>> import pylab >>> >>> x = scipy.arange(100) >>> y = scipy.rand(100) + 1000006 >>> >>> pylab.figure() >>> pylab.plot(x,y) >>> pylab.grid() >>> >>> pylab.show() >>> >>> This gives the y-limits as (0,1) with respect to 1000006. This makes >>> it very hard to read. I'd like to be able to configure this manually. >>> >>> Thanks in advance, >>> Daniel ------------------------------------------------------------------------------ Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users