-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Colorbar grid position #18575
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
Merged
Merged
Colorbar grid position #18575
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
9ac3c86
update colorbar.py make_axes_gridspec
82486c5
Update colorbar.py
a55b35c
fix `wh_ratios` orientation in `make_axes_gridspec`
2c2a4ae
add tests for cbar anchor
d1e6266
rewrite test and factored out duplicate code
7bf9180
Merge branch 'master' into colorbarGridPosition
a4e32ee
modify the gallery example of colorbar
b356530
Merge branch 'colorbarGridPosition' of https://github.com/ShawnChen19…
979ecee
flake8 compliance
9365767
flake8 compliance
74f5f48
add different senarioes for anchored_cbar_position_using_specgrid
af63301
Update examples/color/colorbar_basics.py
762f61b
Update lib/matplotlib/tests/test_colorbar.py
682082a
Update lib/matplotlib/tests/test_colorbar.py
0548c97
Update lib/matplotlib/tests/test_colorbar.py
003ecf6
Update lib/matplotlib/tests/test_colorbar.py
7e0207c
Update lib/matplotlib/tests/test_colorbar.py
6e117ff
rename wh_ratios to height_ratios/width_ratios
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand why the anchor point
p0
should be affected byshrink
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p0
is not affected byshrink
,cy1
is the top of colorbar axes, which can be calculated usingp0
andshrink
cy1 = y1 * shrink + (1 - shrink) * p0
while
p0
andshrink
do not affect each otherThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not saying they affect each other; I'm saying that
shrink
has an effect onp0
forcy0
/cy1
, and I don't know why. Ifp0
is an anchor, then it should not get shrunk.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at this again, and
anchor
is the anchor point of the colorbar, while I was thinking it was the anchor on the parent Axes, but that's defined bypanchor
. So this is why I was confused by this calculation.However, that means that
p0
doesn't seem to be calculated right, as it is calculating an anchor position in the parent Axes space (usingy0
/y1
), but usinganchor_y
, which was used for the colorbar anchor position.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the test function, I will take
location=right
as an examplethe x0 y0 x1 y1 for the plot axes is [0.125, 0.11, 0.745, 0.88] (rounded to 2 digits) , blue region
the cx0 cy0 cx1 cy1 for cbar is [0.78, 0.22, 0.80, 0.61] , orange region
the p0 is the absolute y postion (red dot) of colorbar anchor against the plot, while anchor-y is a relative colorbar postion against the parent axes,
thus
p0-y0 = (y1-y0) * anchor_y
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed the y value for colorbar anchor is the relative postion against the plot, not the absolute y position. Correct me if I am wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ShawnChen1996 I think what would be convincing would be an example that shows clearly this version does close to the same as the version with
use_gridspec=False
, just to make sure the semantics are the same foranchor
andpanchor
. For completeness it would be good if the were tested at more than one anchor along all four sides.I know below we suggested not making an image test, but it would be helpful to see what the image looks like, even if it doesn't make it into the test. I guess in situations like this, I actually lean towards adding an image test since its hard to tell by looking at the numbers if things are working. But at least for review, it would be super helpful to see the image.
If the kwargs are being used the same as the old meaning of the kwargs, then we still have a documentation issue, but that shouldn't block this PR.