79189218

Date: 2024-11-14 14:44:27
Score: 2.5
Natty:
Report link

Is this what you mean?

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap

x = [1, 2, 3, 4, 5]
y1 = [1, 1, 2, 3, 5]
y2 = [0, 4, 2, 6, 8]
y3 = [1, 3, 5, 7, 9]

y = np.vstack([y1, y2, y3])

labels = ["Fibonacci", "Evens", "Odds"]

fig, ax = plt.subplots()

# Create a custom colormap
cmap = LinearSegmentedColormap.from_list("custom_cmap", ["green", "transparent"])

# Plot the first two areas normally
ax.stackplot(x, y1, y2, labels=labels[:2])

# Plot the "Odds" area with a gradient
for i in range(len(x) - 1):
    ax.fill_between(x[i:i+2], y1[i:i+2] + y2[i:i+2], y1[i:i+2] + y2[i:i+2] + y3[i:i+2], 
                    color=cmap(i / (len(x) - 1)))

ax.legend(loc='upper left')
plt.show()
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Starts with a question (0.5): Is this
  • Low reputation (1):
Posted by: GaTe