-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix colorbar exponents #22313
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
Fix colorbar exponents #22313
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 |
---|---|---|
|
@@ -2474,8 +2474,13 @@ def _update_offset_text_position(self, bboxes, bboxes2): | |
Update the offset_text position based on the sequence of bounding | ||
boxes of all the ticklabels | ||
""" | ||
x, y = self.offsetText.get_position() | ||
top = self.axes.bbox.ymax | ||
x, _ = self.offsetText.get_position() | ||
if 'outline' in self.axes.spines: | ||
# Special case for colorbars: | ||
bbox = self.axes.spines['outline'].get_window_extent() | ||
else: | ||
bbox = self.axes.bbox | ||
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. Would it make sense to update the 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.
Another alternative is to turn the axis off, use 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. I try to paraphrase: the colorbar axes has additional decorations which are outside the bbox but need to be taken into accout for shifting the offset text? In that case, do we need a concept for "bbox with decorations"? 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. We do, it's called get_tightbbox. However that is defined on the axes and takes into account the axis, and this exponent is part of the axis, so you get an infinite recursion. I guess we could change get_tightbbox to accept a list of artists to exclude, but I'm not convinced that is any better than this solution. And again get_tightbbox can be very expensive. 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. Thanks for the explanation. I don't claim to I know how the correct or practical solution. I was just trying to understand what's going on. |
||
top = bbox.ymax | ||
self.offsetText.set_position( | ||
(x, top + self.OFFSETTEXTPAD * self.figure.dpi / 72) | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -505,7 +505,7 @@ def my_plotter(ax, data1, data2, param_dict): | |
|
||
pc = axs[1, 1].scatter(data1, data2, c=data3, cmap='RdBu_r') | ||
fig.colorbar(pc, ax=axs[1, 1], extend='both') | ||
axs[1, 1].set_title('scatter()'); | ||
axs[1, 1].set_title('scatter()') | ||
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. these semicolons dont' work anyways, so removed it here... |
||
|
||
############################################################################## | ||
# Colormaps | ||
|
Uh oh!
There was an error while loading. Please reload this page.