-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Labels
Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.topic: color/colorbar
Milestone
Description
Bug summary
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.
Code for reproduction
import matplotlib.pyplot as plt
import numpy as np
xs = np.random.rand(100)
_, bin_edges, bars = plt.hist(xs)
color_map = getattr(plt.cm, "hot")
for x_val, rect in zip(bin_edges, bars.patches):
rect.set_color(color_map(x_val))
cbar = plt.colorbar(
plt.cm.ScalarMappable(cmap=color_map),
# cax=ax.inset_axes([0.95, 0.1, 0.05, 0.8]),
)
Actual outcome
In matplotlib==3.6.0
:
Expected outcome
In matplotlib==3.5.1
:
Operating system
macOS 12.6
Matplotlib Version
3.6.0
Python version
3.10
Installation
pip
Metadata
Metadata
Assignees
Labels
Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.topic: color/colorbar