-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX: fix colorbars with no scales #20327
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -771,3 +771,17 @@ def test_inset_colorbar_layout(): | |
np.testing.assert_allclose(cb.ax.get_position().bounds, | ||
[0.87, 0.342, 0.0237, 0.315], atol=0.01) | ||
assert cb.ax.outer_ax in ax.child_axes | ||
|
||
|
||
@image_comparison(['colorbar_twoslope.png'], remove_text=True, | ||
style='mpl20') | ||
def test_twoslope_colorbar(): | ||
# Note that the first tick = 20, and should be in the middle | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding the ticklabels to the image would be helpful here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I agree, but we really try to avoid labels, because they cause image comparison problems when the font library changes... |
||
# of the colorbar (white) | ||
fig, ax = plt.subplots() | ||
|
||
norm = mcolors.TwoSlopeNorm(20, 0, 100) | ||
pc = ax.pcolormesh(np.arange(1, 11), np.arange(1, 11), | ||
np.arange(100).reshape(10, 10), | ||
norm=norm, cmap='RdBu_r') | ||
fig.colorbar(pc) |
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.
Note downstream libraries will likely derive from Normalize, so scale should be None so their norm gets used...
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.
@dstansby can you see if this version works?
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.
Yep, seems to work well with this version.
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.
Any chance of a formal review?