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

Fix scale factor label issue #4043 #4097

Merged
merged 5 commits into from Feb 16, 2015
Merged

Conversation

lichri12
Copy link
Contributor

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.

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.
@tacaswell tacaswell added this to the 1.5.0 milestone Feb 13, 2015
@tacaswell
Copy link
Member

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.

@lichri12
Copy link
Contributor Author

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()

And I got this
figure_1

As you can see in the second graph, now the label 1e-11 is on the right side with the ticks

@tacaswell
Copy link
Member

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
@lichri12
Copy link
Contributor Author

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
@lichri12
Copy link
Contributor Author

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

@tacaswell
Copy link
Member

It looks like pep8 has gone and updated it's self again, don't worry about those errors for now.

tacaswell added a commit that referenced this pull request Feb 16, 2015
BUG : Move offset text with tick labels

closes #4043
@tacaswell tacaswell merged commit 08b8adb into matplotlib:master Feb 16, 2015
@tacaswell
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

2 participants