FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix: Log Colorbar minorticks_off reverted if ticks set by LevN0 · Pull Request #13351 · matplotlib/matplotlib · GitHub

Repository navigation

Fix: Log Colorbar minorticks_off reverted if ticks set - #13351

Merged
NelleV merged 1 commit into
matplotlib:masterfrom
LevN0:fix-log-colorbar-minorticks-revert-set-ticks
Feb 4, 2019
Merged

NelleV merged 1 commit into
matplotlib:masterfrom
LevN0:fix-log-colorbar-minorticks-revert-set-ticks

Conversation

LevN0 commented Feb 3, 2019

Copy link
Copy Markdown
Contributor

PR Summary

Closes #13339.

Fixes issue where colorbar lognorm minorticks are turned back on anytime ticks are updated.

Before

Any time ColorbarBase.update_ticks is called, it forces minorticks on for LogNorm. Calling methods like set_ticks therefore reverts the action of minorticks_off.

fig, ax = plt.subplots()

data = np.clip(randn(250, 250)*1000, 0, 1000)

cax = ax.imshow(data, norm=mpl.colors.LogNorm(vmin=1, vmax=1000))
cbar = fig.colorbar(cax, format='%d')

cbar.minorticks_off()
cbar.set_ticks([5, 10, 100])

plt.show()

Produces,

(Note minorticks come back on, after being explicitly turned off.)

After

Minorticks stay off after being manually turned off.

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

LevN0 commented Feb 3, 2019

Copy link
Copy Markdown
Contributor Author

Should I add a unit test?

If so, would I adjust one I wrote a few days ago to test minorticks can be turned off for LogNorm to also add this condition (e.g. just add set_ticks after minorticks_off, prior to testing they are really off), or leave those tests alone and write a separate one (that would still do the above)?

NelleV commented Feb 3, 2019

Copy link
Copy Markdown
Member

@LevN0 Yes, a unit test is in order.

Either adding a new one, or adding checks to an existing one is fine.

jklymak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks right to me, subject to a test in test_colorbar.py (preferably one w/o a new image)

LevN0 force-pushed the fix-log-colorbar-minorticks-revert-set-ticks branch from 14fad1c to 6ba23b8 Compare February 3, 2019 17:28

LevN0 commented Feb 3, 2019

Copy link
Copy Markdown
Contributor Author

Added a test.

Comment thread lib/matplotlib/colorbar.py Outdated
self.ax.set_xscale('log')
self.ax.set_yscale('log')

if type(self.norm) == colors.LogNorm:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

OK, actually we don't need the check here, do we?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

That is a very good point.

LevN0 force-pushed the fix-log-colorbar-minorticks-revert-set-ticks branch from 16d3377 to 347f65b Compare February 4, 2019 01:58
Fixes issue where colorbar lognorm minorticks are turned back on anytime
ticks are updated
LevN0 force-pushed the fix-log-colorbar-minorticks-revert-set-ticks branch from e8a5d91 to ffaaabd Compare February 4, 2019 02:09

NelleV commented Feb 4, 2019

Copy link
Copy Markdown
Member

This looks good! Thanks!

NelleV merged commit 3ad9be2 into matplotlib:master Feb 4, 2019
QuLogic added this to the v3.1.0 milestone Feb 4, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

4 participants


Back | FazBrowse Home | New Git URL