bug with twinx and scientific style

Hi there,

when I use twinx() to have y1 and y2 axes and set ticklabel_format style to 'sci' on the y2 axis, ticks on the y2 are properly numbered, but the "1e-5" that is supposed to be atop y2 appears on the top of y1 instead. When both y1 and y2 use the exponents, they overwrite each other -- a minimal example (result attached in pdf):

import pylab

pylab.plot([0,1e-2,2e-2,3e-2],[1e3,5e3,6.1e3,1e3],'g-')

pylab.ticklabel_format(style='sci',scilimits=(0,0),axis='both') # this is not necessary to show the bug

pylab.twinx()

pylab.plot([1e-2,2e-2,3e-2,4e-2],[2e-5,3e-5,0,-1e-5],'r-')

pylab.ticklabel_format(style='sci',scilimits=(0,0),axis='both') # makes 1e-5 appear on the left instead of on the right

pylab.show()

I've had this issue with versions .99, 1.0.0, running on Linux (Ubuntu, versions 9.04 through to 10.10).

Cheers, Václav

PS. what's wrong with the sf.net bugzilla? I was not able to post the issue there --

overlap.pdf (6.64 KB)

Václav Šmilauer, on 2010-12-23 14:51, wrote:

Hi there,

when I use twinx() to have y1 and y2 axes and set ticklabel_format
style to 'sci' on the y2 axis, ticks on the y2 are properly numbered,
but the "1e-5" that is supposed to be atop y2 appears on the top of
y1 instead. When both y1 and y2 use the exponents, they overwrite
each other -- a minimal example (result attached in pdf):

import pylab

pylab.plot([0,1e-2,2e-2,3e-2],[1e3,5e3,6.1e3,1e3],'g-')

pylab.ticklabel_format(style='sci',scilimits=(0,0),axis='both') # this is not necessary to show the bug

pylab.twinx()

pylab.plot([1e-2,2e-2,3e-2,4e-2],[2e-5,3e-5,0,-1e-5],'r-')

pylab.ticklabel_format(style='sci',scilimits=(0,0),axis='both') # makes 1e-5 appear on the left instead of on the right

pylab.show()

Hi Václav,

thanks for the bug report. As a temporary workaround - use

plt.gca().yaxis.set_offset_position('right')

Committers: the patch attached fixes this problem. I thought that
there might be a similar problem for twiny() - but ax.xaxis does
not appear to have .set_offset_position() method.

I've had this issue with versions .99, 1.0.0, running on Linux
(Ubuntu, versions 9.04 through to 10.10).

me too, and I kept forgetting to report it.

PS. what's wrong with the sf.net bugzilla? I was not able to post the
issue there --

this I do not know.

best,

twinx-sci.diff (833 Bytes)

···

--
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7