You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: ValueError: Unable to determine Axes to steal space for Colorbar. #23973
matplotlib==3.6.0 started raising an error when trying to add a colorbar to plt.hist():
ValueError: Unable to determine Axes to steal space for Colorbar. Either provide the cax argument to use as the Axes for the Colorbar, provide the ax argument to steal space from it, or add mappable to an Axes.
You could make an axes, and use that, but you will lose some layout convenience.
Reacted by Janosh Riebesell, Li Jiangkun, Burçak Otlu, Siebren Frölich, hoho2b, Jakub Simanek, amir-hoseyn77, clnbtlr, Martin Husek, mzechmeister and 9 more
I had the problem when trying to use create a simple SHAP plot using the shap package.
importshap# use SHAP (SHapley Additive exPlanations) to explain the output of the generated modelexplainer=shap.TreeExplainer(model)
shap_values=explainer.shap_values(X)
shap.summary_plot(shap_values[1], X, feature_names=X.columns, show=False, max_display=20, plot_size=(15, 10))
ValueError: Unable to determine Axes to steal space for Colorbar. Either provide the cax argument to use as the Axes for the Colorbar, provide the ax argument to steal space from it, or add mappable to an Axes.
I had to downgrade to matplotlib 3.5.1 to fix the issue.
Reacted by AusnUnia, lwjkl, Abner Guzman-Rivera, adam-marciniak-ryvu, Renata Santos, NNNightglow, Diana Omelianchyk and Mohammad Gharb
I will put on the agenda for next weeks call what we should do about this. It seems we screwed up the deprecation warning somehow, or a lot of downstream packages didn't see it.
I guess this should get fixed for the bug release, though maybe not the most critical thing in the world. But we have probably broken a few libraries by doing this with no notice.
Is it possible to reopen this issue? I'm having the same problem with version 3.9.2. I can only plot my graphs (pyprocar and vaspkit) when I downgrade to version 3.4.2(3)
You can open a new issue, but the behaviour was deprecated, so unless there is a strong reason, you will have to either use old Matplotlib, or take the problem up with pyprocar and vaspkit.
Activity
janosh commentedon Sep 21, 2022
The error disappears in 3.6.0 by following the error message and passing
cax=ax.inset_axes([0.95, 0.1, 0.05, 0.8]).jklymak commentedon Sep 21, 2022
If it is ambiguous what axes to use, pass in the axes directly:
You could make an axes, and use that, but you will lose some layout convenience.
janosh commentedon Sep 21, 2022
Good to know I can keep auto-layout for the color bar.
What changed between 3.5.1 and 3.6.0? Why wasn't it ambiguous before?
jklymak commentedon Sep 21, 2022
This happened in #23740. However, I think we were under the impression this was deprecated, but it sounds like perhaps that was not the case?
jvmunhoz commentedon Sep 30, 2022
I had the problem when trying to use create a simple SHAP plot using the shap package.
ValueError: Unable to determine Axes to steal space for Colorbar. Either provide the cax argument to use as the Axes for the Colorbar, provide the ax argument to steal space from it, or add mappable to an Axes.I had to downgrade to matplotlib 3.5.1 to fix the issue.
jklymak commentedon Sep 30, 2022
Please report to shap
I will put on the agenda for next weeks call what we should do about this. It seems we screwed up the deprecation warning somehow, or a lot of downstream packages didn't see it.
rcomer commentedon Sep 30, 2022
There was a deprecation warning here, but it was only triggered if the mappable had an axes that was different from the current axes:
matplotlib/lib/matplotlib/figure.py
Lines 1182 to 1191 in a86271c
In the OP's case, I think the mappable has no axes.
jklymak commentedon Sep 30, 2022
I guess this should get fixed for the bug release, though maybe not the most critical thing in the world. But we have probably broken a few libraries by doing this with no notice.
TheGreatDeadOne commentedon Sep 6, 2024
Is it possible to reopen this issue? I'm having the same problem with version 3.9.2. I can only plot my graphs (pyprocar and vaspkit) when I downgrade to version 3.4.2(3)
jklymak commentedon Sep 6, 2024
You can open a new issue, but the behaviour was deprecated, so unless there is a strong reason, you will have to either use old Matplotlib, or take the problem up with pyprocar and vaspkit.
move plot_defaults.py into pymatviz pkg
move plot_defaults.py into pymatviz pkg