FIX: make EngFormatter respect axes.unicode_minus rcParam by pharshalp · Pull Request #13477 · matplotlib/matplotlib · GitHub
Skip to content

FIX: make EngFormatter respect axes.unicode_minus rcParam - #13477

Merged
timhoffm merged 5 commits into
matplotlib:masterfrom
pharshalp:EngFixMinus
Mar 3, 2019
Merged

FIX: make EngFormatter respect axes.unicode_minus rcParam#13477
timhoffm merged 5 commits into
matplotlib:masterfrom
pharshalp:EngFixMinus

Conversation

@pharshalp

Copy link
Copy Markdown
Contributor

PR Summary

EngFormatter was not respecting the axes.unicode_minus rcParam.

Example (old behavior)

import matplotlib.pyplot as plt
from matplotlib.ticker import EngFormatter
plt.rc('font', size=14)
fig, ax = plt.subplots(figsize=(4.0, 2.5), constrained_layout=True)
ax.plot([-10000, -5000, 0, 5000, 10000], [-10000, -5000, 0, 5000, 10000], '*-')
formatter = EngFormatter()
ax.xaxis.set_major_formatter(formatter)
ax.yaxis.set_major_formatter(formatter)
fig.savefig('old_EngFormatter.png', dpi=200)

test

Example (New behavior)

test_new

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@tacaswell tacaswell added this to the v3.2.0 milestone Feb 21, 2019
Comment thread lib/matplotlib/ticker.py
@anntzer

anntzer commented Feb 21, 2019

Copy link
Copy Markdown
Contributor

@pharshalp pharshalp changed the title FIX: make EngFormatter respect axes.unicode_minus rcParam [WIP] FIX: make EngFormatter respect axes.unicode_minus rcParam Feb 21, 2019
@pharshalp

Copy link
Copy Markdown
Contributor Author

working on updating the failing tests to ensure both cases (with and without unicode minus) are checked (current tests don't include unicode minus).

@pharshalp pharshalp changed the title [WIP] FIX: make EngFormatter respect axes.unicode_minus rcParam FIX: make EngFormatter respect axes.unicode_minus rcParam Feb 24, 2019
@pharshalp

Copy link
Copy Markdown
Contributor Author

Updated the test to make it pass. Should I be checking for the non-default value of the rcParam axes.unicode_minus=False? The current test assumes the default value of the rcParam axes.unicode_minus=True.

@anntzer

anntzer commented Feb 25, 2019

Copy link
Copy Markdown
Contributor

rcparams are always reset to their defaults before running the tests.

I guess adding a test that things work as expected when the rcParam is changed before creating the formatter would be nice, but not compulsory.

@pharshalp

Copy link
Copy Markdown
Contributor Author

Updated the test to check for the non-default value of axes.unicode_minus rcParam. I think this is ready for review.

Comment thread lib/matplotlib/tests/test_ticker.py Outdated

@anntzer anntzer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modulo ci

Comment thread lib/matplotlib/tests/test_ticker.py
@timhoffm timhoffm modified the milestones: v3.2.0, v3.1.0 Mar 3, 2019
@timhoffm

timhoffm commented Mar 3, 2019

Copy link
Copy Markdown
Member

Remilestoning to 3.1. It's good to get this in.

@timhoffm
timhoffm merged commit aed13c1 into matplotlib:master Mar 3, 2019
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Mar 3, 2019
@pharshalp

Copy link
Copy Markdown
Contributor Author

@pharshalp
pharshalp deleted the EngFixMinus branch March 3, 2019 21:32
QuLogic added a commit that referenced this pull request Mar 3, 2019
…477-on-v3.1.x

Backport PR #13477 on branch v3.1.x (FIX: make EngFormatter respect axes.unicode_minus rcParam)
@pharshalp
pharshalp restored the EngFixMinus branch April 29, 2019 01:43
@pharshalp
pharshalp deleted the EngFixMinus branch January 27, 2020 17:05
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.

5 participants