| [ Web Proxy ] |
| Viewing: https://matplotlib.org/stable/api/_as_gen/../../gallery/misc/../mplot3d/fillunder3d.html | [Back] [Original] |
Section Navigation
fill_between with transparencyhisttype settingsplt.subplotsfloating_axes featuresNote
Go to the end to download the full example code.
Demonstrate how to create polygons which fill the space under a line graph. In this example polygons are semi-transparent, creating a sort of 'jagged stained glass' effect.
import math
import matplotlib.pyplot as plt
import numpy as np
gamma = np.vectorize(math.gamma)
N = 31
x = np.linspace(0., 10., N)
lambdas = range(1, 9)
ax = plt.figure().add_subplot(projection='3d')
facecolors = plt.colormaps['viridis_r'](np.linspace(0, 1, len(lambdas)))
for i, l in enumerate(lambdas):
# Note fill_between can take coordinates as length N vectors, or scalars
ax.fill_between(x, l, l**x * np.exp(-l) / gamma(x + 1),
x, l, 0,
facecolors=facecolors[i], alpha=.7)
ax.set(xlim=(0, 10), ylim=(1, 9), zlim=(0, 0.35),
xlabel='x', ylabel=r'$\lambda$', zlabel='probability')
plt.show()
[fillunder3d]Tags: plot-type: 3D plot-type: fill_between level: beginner
Copyright 20022012 John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the Matplotlib development team; 20122026 The Matplotlib development team.
Created using Sphinx 9.1.0.
Built from v3.11.2-1-g879ad8ebba.
Built with the PyData Sphinx Theme 0.16.1.
| Web Proxy Viewer | New URL | Original Page |