Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

twiny overrides formatter and adds another x-axis #1110

Closed
mdboom opened this issue Aug 19, 2012 · 1 comment
Closed

twiny overrides formatter and adds another x-axis #1110

mdboom opened this issue Aug 19, 2012 · 1 comment

Comments

@mdboom
Copy link
Member

mdboom commented Aug 19, 2012

Christopher Graves reported this on the mailing list:

I do not think this is the expected behavior. First, run the following:

from pylab import *

plot([0,3],[0.2,0.7])

ax1 = gca()

ax1.set_yscale('log')

gca().yaxis.set_major_formatter(FormatStrFormatter('$%g$'))

#ax2 = ax1.twiny()

#ax2.set_xlim(ax1.get_xlim())

show()

You will see that the y-axis is log10rithmic and axis labels are 0.1 and 1 rather than 10^-1 and 10^0, due to the use of set_major_formatter().

Now uncomment the 2 commented lines and run it again. It seems that upon applying a twiny(), the set_major_formatter() action is removed and the y-axis is now displayed as 10^-1 and 10^0. Or more likely, the y-axis is "overwritten" with a new y-axis present in ax2. One can add another gca().yaxis.set_major_formatter(FormatStrFormatter('$%g$')) before the show() and it works as intended. However, it seems like unexpected behavior to "lose" the formatting when twinning the axis to add a secondary x-axis. Any advice or agreement that this could be a bug?

Best,

Chris

@dmcdougall
Copy link
Member

This issue can be closed now. It has been resolved with #1145.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants