fill_between
has been extended to 3D axes as of matplotlib v3.10.0, making this easier to plot. Here's a demonstration based on @armatita's example:
import numpy as np
import matplotlib.pyplot as plt
# Generate some random data
w = 3
x, y = np.arange(100), np.random.randint(0, 100 + w, 100)
z = np.array([y[i - w:i + w].mean() for i in range(3, 100 + w)])
y = np.zeros(x.shape)
fig, ax = plt.subplots(1,1,subplot_kw={'projection':'3d'})
ax.fill_between(x, y, z, x, 0, 0, color='orange', linewidth=0, alpha=0.5)
ax.plot(x, y, z)
plt.show()
The new axlim_clip=True
argument has also been added to all 3D plotting functions in this version, to ensure your data does not plot outside the axes limits.
ax.fill_between(x, y, z, x, 0, 0, color='orange', linewidth=0, alpha=0.5, axlim_clip=True)
ax.plot(x, y, z, axlim_clip=True)