Title: ENH: fix colorbar bad minor ticks by pharshalp · Pull Request #11584 · matplotlib/matplotlib · GitHub
Open Graph Title: ENH: fix colorbar bad minor ticks by pharshalp · Pull Request #11584 · matplotlib/matplotlib
X Title: ENH: fix colorbar bad minor ticks by pharshalp · Pull Request #11584 · matplotlib/matplotlib
Description: PR Summary This follows the suggestion given in #11556 and builds a method for colorbar to correctly display minor ticks (without extending into the region beyond vmin, vmax when the extend option is used). Earlier, the only way to display the minor ticks was to use ax.minorticks_on/off methods (which didn't respect vmin, vmax values). With this PR, the colorbar gets its own minorticks_on/off methods. Fixes #11510 and is a follow up to #11556 . @jklymak Could you please review this? This builds on top of your suggestions in the discussion here #11556, #11510. This is my first (relatively significant) contribution to matplotlib (apart from a minor documentation entry) so I would appreciate any help in how to properly document API change (or if I am missing anything else). I am marking this as WIP since I am not sure how to add tests and other entries from the PR checklist (I will try to understand the requirements for each item in the list and will work on those soon). PR Checklist Has Pytest style unit tests Code is PEP 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 Correct behavior (after the PR) import matplotlib.pyplot as plt import numpy as np # Making yticks longer in length to highlight the issue plt.rcParams['ytick.major.size'] = 10 plt.rcParams['ytick.minor.size'] = 4 np.random.seed(seed=12345) x = np.random.randn(20, 20) fig, ax = plt.subplots() im = ax.pcolormesh(x) cbar = fig.colorbar(im, extend='both') ### Colorbar gets its own minorticks_on() method cbar.minorticks_on() plt.show() Incorrect behavior import matplotlib.pyplot as plt import numpy as np # Making yticks longer in length to highlight the issue plt.rcParams['ytick.major.size'] = 10 plt.rcParams['ytick.minor.size'] = 4 np.random.seed(seed=12345) x = np.random.randn(20, 20) fig, ax = plt.subplots() im = ax.pcolormesh(x) cbar = fig.colorbar(im, extend='both') ### older way of adding minorticks (which had incorrect behavior) cbar.ax.minorticks_on() plt.show()
Open Graph Description: PR Summary This follows the suggestion given in #11556 and builds a method for colorbar to correctly display minor ticks (without extending into the region beyond vmin, vmax when the extend option ...
X Description: PR Summary This follows the suggestion given in #11556 and builds a method for colorbar to correctly display minor ticks (without extending into the region beyond vmin, vmax when the extend option ...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/11584
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:2ebc4e3f-32b0-5849-a9de-9830d4da0459 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8396:3D4E09:A25438:DCE0A5:6A55A92F |
| html-safe-nonce | 66965d57d21d046bee42a27d39b5d96190fddd9b326c3e96c8f83c611fa0b505 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Mzk2OjNENEUwOTpBMjU0Mzg6RENFMEE1OjZBNTVBOTJGIiwidmlzaXRvcl9pZCI6IjU5NTU0Njk4NTg0OTgyNTkyNDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 539499b5d240f950e1a8ab9cc5af864b58faa1588c890263ed3cd776ff1f4171 |
| hovercard-subject-tag | pull_request:199634303 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/matplotlib/matplotlib/pull/11584/files |
| twitter:image | https://avatars.githubusercontent.com/u/15175620?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/15175620?s=400&v=4 |
| og:image:alt | PR Summary This follows the suggestion given in #11556 and builds a method for colorbar to correctly display minor ticks (without extending into the region beyond vmin, vmax when the extend option ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b5665c84831ed9ac4fb79519c16c9c5580ba8092fb8bb6e3e72972ec7197348e |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 653fccf1e27344851c0d3de3fa6faa526197f072 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width