Created
May 12, 2021 13:50
-
-
Save AayushSameerShah/852546e913e782d04abbc09595e0f6f5 to your computer and use it in GitHub Desktop.
This will give the shaded region in a graph... main part is under # Make shaded region comment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SIMPLE chhe, Don't worry... | |
def func(x): | |
return x ** 2 | |
x = np.linspace(0, 10) | |
y = func(x) | |
fig, ax = plt.subplots() | |
ax.plot(x, y, 'r', linewidth=2) | |
ax.set_ylim(bottom=0) | |
# Make the shaded region | |
a, b = 2, 9 # integral limits | |
ix = np.linspace(a, b) | |
iy = func(ix) | |
verts = [(a, 0), *zip(ix, iy), (b, 0)] | |
poly = Polygon(verts, facecolor='0.9', edgecolor='0.5') | |
ax.add_patch(poly) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here bro...
https://matplotlib.org/stable/gallery/showcase/integral.html#sphx-glr-gallery-showcase-integral-py