0

So im getting this error: TypeError: object of type 'LinearSegmentedColormap' has no len()

Im trying to create a bar plot with a color map

from matplotlib import colormaps

my_cmap = colormaps["coolwarm"]


fig, color_bars = plt.subplots()
plt.bar(year, above, color=my_cmap, width=5)
plt.show()

the x and y value words however it seems as if the color won't work. I also tried:

from matplotlib import colormaps

my_cmap = colormaps["coolwarm"]


fig, color_bars = plt.subplots()
plt.bar(year, above, cmap=my_cmap, width=5)
plt.show()

which gave me this error: AttributeError: Rectangle.set() got an unexpected keyword argument 'cmap'

any help would be greatly appreciated!

from matplotlib import colormaps

my_cmap = colormaps["coolwarm"]


fig, color_bars = plt.subplots()
plt.bar(year, above, color=my_cmap, width=5)
plt.show()
from matplotlib import colormaps

my_cmap = colormaps["coolwarm"]


fig, color_bars = plt.subplots()
plt.bar(year, above, cmap=my_cmap, width=5)
plt.show()

0 Answers0