如何在matplotlib中的曲线下阴影区域 [英] How to shade region under the curve in matplotlib
本文介绍了如何在matplotlib中的曲线下阴影区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用matplotlib来说明两个区域之间的定积分:x_0和x_1.
I want to use matplotlib to illustrate the definite integral between two regions: x_0, and x_1.
在给定以下图的情况下,如何在matplotlib中的曲线下的阴影区域从x = -1到x = 1着色
How can I shade a region under a curve in matplotlib from x=-1, to x=1 given the following plot
import numpy as np
from matplotlib import pyplot as plt
def f(t):
return t * t
t = np.arange(-4,4,1/40.)
plt.plot(t,f(t))
推荐答案
Check out fill
. Here's an example on filling a constrained region.
这篇关于如何在matplotlib中的曲线下阴影区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文