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
Fix scale factor label issue #4043 #4097
Conversation
Added the line, self.set_offset_position(position) in the YAxis class (line 2026) and it appears to fix the issue of the scale factor label not moving to the right with the tick labels.
Thanks for this! It is always nice when things have simple fixes. Could you also write a test? I don't think this needs an image test, just to verify that the offset text is now on the opposite side of the axes. |
So for testing I used the same code as the one used in the Issue #4043 ticket import numpy
from matplotlib import pyplot
data = numpy.random.random(1e4) * 1e-22
fig, axes = pyplot.subplots(2, 1, sharex=True)
axes[0].plot(data)
axes[1].plot(data ** (.5))
axes[1].yaxis.set_label_position('right')
axes[1].yaxis.tick_right() As you can see in the second graph, now the label 1e-11 is on the right side with the ticks |
We have a suite of automated tests that are run on every PR (see the green check mark next to your commit in this thread) to make sure bugs we have fixed don't come back and that new features don't break back compatibility. For this I think something like @cleanup
def test_move_offsetlabel()
data = numpy.random.random(10) * 1e-22
fig, ax = pyplot.subplots()
ax.plot(data)
ax.yaxis.tick_right()
assert(something that checks the offset text is on the right) |
Added a test to check whether offseting a label works
Meant to say test in commit message and not text |
Updated where I put the line self.set_offset_position(position) to better fit the description of the bug
Updated the test to match the bug fix
I have added tests and updated my bug fix to better match the description of the bug, however I am having trouble passing the PEP-8 test |
It looks like pep8 has gone and updated it's self again, don't worry about those errors for now. |
BUG : Move offset text with tick labels closes #4043
Thanks! |
Added the line, self.set_offset_position(position) in the YAxis class (line 2026) and it appears to fix the issue of the scale factor label not moving to the right with the tick labels.