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

Add location keyword argument to Colorbar by oscargus · Pull Request #23267 · matplotlib/matplotlib · GitHub

Repository navigation

Add location keyword argument to Colorbar - #23267

Merged
jklymak merged 1 commit into
matplotlib:mainfrom
oscargus:colorbarlocation
Nov 7, 2022
Merged

jklymak merged 1 commit into
matplotlib:mainfrom
oscargus:colorbarlocation

Conversation

oscargus commented Jun 14, 2022 •
edited
Loading

Copy link
Copy Markdown
Member

PR Summary

Closes #22676

Is this an API change or a user change?

Will add an unrelated test for #23260 here as well. Added. However, they do not look great... The png looks OK, but locally I get in Spyder:

so there it seems like there is a bit of overlap that is not visible in the test image. For the svg there is a gap instead, although this seems to depend on the renderer...

Also, I do not understand why the test images are not just four squares as the pasted image...

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • [N/A] API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

Copy link
Copy Markdown
Member Author

I also realized that there is a change here that may not really be wanted (or it may be). Earlier, passing e.g. orientation='horizontal' always gave ticklocation 'bottom'. Now, if passing orientation='horizontal' and a valid location, the ticklocation depends on if the location is 'top' or 'bottom'. Which makes sense and is consistent with what location does for make_axis and make_axis_gridspec.

oscargus force-pushed the colorbarlocation branch 2 times, most recently from bdb43a3 to f44b0b4 Compare June 18, 2022 09:01
oscargus marked this pull request as ready for review June 18, 2022 09:05

story645 commented Jun 19, 2022 •
edited
Loading

Copy link
Copy Markdown
Member

This is awesome and I'm fairly sure should get a new feature/what's new write up.

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

Agree with the need for a what's-new.


The ``colorbar`` method now supports a ``location`` keyword argument
to more easily position the color bar. This is useful when providing
your own inset axes using the ``cax`` keyword argument and behaves

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

this sounds like this kwarg only works with a passed in cax & if that's not the case than please also add an example for the not-cax case

Copy link
Copy Markdown
Member 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

The earlier version is documented, but is not used by colorbar (passed to either make_axes or make_axes_gridspec. I agree, however, that the current formulation is not ideal. Will try to modify it (now that I reminded myself of the differences).

timhoffm 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

I've not yet followed the details here, but I would have expected that this can build on top of _normalize_location_orientation. Am I wrong there?

oscargus commented Jun 22, 2022 •
edited
Loading

Copy link
Copy Markdown
Member Author

_normalize_location_orientation also sets anchor, panchor and pad. I wasn't sure that one wanted those to be modified here? Also, here we need to keep the original value of location to keep track of if location and orientation was passed.

So while it could be used, it couldn't just be used to update the kwargs and it would do some additional stuff as well, which seemed redundant to me (but now there is redundant code instead...).

Copy link
Copy Markdown
Member Author

I'll think it through more carefully, but the rationale at the time was this.

Copy link
Copy Markdown
Member

So while it could be used, it couldn't just be used to update the kwargs and it would do some additional stuff as well, which seemed redundant to me (but now there is redundant code instead...).

I'll think it through more carefully, but the rationale at the time was this.

You could also introduce a lower-level function that is used here and inside of _normalize_location_orientation to avoid duplication - if that helps.

oscargus marked this pull request as draft July 7, 2022 07:18

Copy link
Copy Markdown
Member Author

Got around to this and at least now it is checked and set in a single location.

oscargus force-pushed the colorbarlocation branch 2 times, most recently from 08c2062 to 0442dd3 Compare August 18, 2022 19:52
oscargus added this to the v3.6.0 milestone Aug 18, 2022
oscargus marked this pull request as ready for review August 18, 2022 19:56
Comment thread lib/matplotlib/tests/test_colorbar.py Outdated
Comment thread lib/matplotlib/colorbar.py Outdated
Comment thread lib/matplotlib/colorbar.py Outdated
tacaswell modified the milestones: v3.6.0, v3.7.0 Aug 19, 2022
oscargus force-pushed the colorbarlocation branch 3 times, most recently from 0515d39 to ee796c5 Compare November 2, 2022 13:31

oscargus commented Nov 2, 2022

Copy link
Copy Markdown
Member Author

Finally got back to this. The unrelated test is dropped.

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

Just a small documentation concern

Comment thread lib/matplotlib/colorbar.py Outdated

filled : bool

location : None or {'left', 'right', 'top', 'bottom'}

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

I think this needs some description about how it interacts with orientation and ticklocation?

Copy link
Copy Markdown
Member 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

I've added a bit of text (copied from the top) and updated the docs for ticklocation. There should maybe be another way to describe how all these are related if only some are given.

QuLogic modified the milestones: v3.7.0, v3.6.3 Nov 3, 2022
jklymak merged commit f975291 into matplotlib:main Nov 7, 2022

jklymak commented Nov 7, 2022

Copy link
Copy Markdown
Member

Thanks @oscargus - definitely useful addition!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH]: Colorbar should support location kwarg that sets both orientation and ticklocation

7 participants


Back | FazBrowse Home | New Git URL