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
BUG: Add Figure.delcolorbar() to fully delete a colorbar #3110
Conversation
This probably does not need a image just, just ask the axes how big it is. |
The colorbar to delete | ||
""" | ||
|
||
self.delaxes(cb.ax) |
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.
What happen in figures with out a colorbar? Sorry, being dumb.
The new diff switches from |
assert (pre_figbox == post_figbox).all() | ||
|
||
|
||
def test_remove_from_figure_with_gridspec(): |
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.
Both tests need and @cleanup
or we get strange effects with tests cross-talking.
Could you please squash this down to a single commit? (so we don't have the addition and removal in our repo forever) |
Artists have a |
I prefer |
I put up a new commit that should address all of the raised issues. I've changed the method name from |
The Travis failure is unrelated. |
mappable.callbacksSM.connect('changed', cb.on_mappable_changed)
mappable.colorbar = cb Also, when pos = ax.get_position(original=True)
ax.set_position(pos) |
With the new commit, the callback and colorbar attribute are reset, and get_position/set_position are called when use_gridspec was False. |
This looks good to merge to me 👍 Thanks for fixing what was a very long standing bug. |
BUG: Add Figure.delcolorbar() to fully delete a colorbar
Closes #2688.
This creates a new Figure.delcolorbar() function, named to mimic Figure.delaxes(). The new function will delete a colorbar. If that colorbar was creating with
use_gridspec=True
, the function will also reset the gridspec. I added two tests to confirm that the function works as intended for colorbars creating withuse_gridspec
set to eitherTrue
orFalse
.