Matplotlib's ax.fill_between
plotting function has the cmap
parameter and I was trying to use it to fill the area under the curve with a gradient.
However, setting cmap
in this function doesn't seem to be doing anything or I'm missing something?
This is what I've tried:
import matplotlib.pyplot as plt
x = [0, 1, 2, 3, 4, 5]
y = [2, 4, 1, 3, 0.5, 2]
fig, ax = plt.subplots(
figsize=(10,6),
facecolor="white"
)
ax.fill_between(
x=x,
y1=y,
cmap="cool"
)
and another version of it:
ax.fill_between(
x=x,
y1=y,
cmap=plt.get_cmap("cool")
)
I would also try to apply cmap
to color
or facecolor
property but it would throw an error.
So all I always end up with is this: