计算两条曲线之间的面积 [英] Calculation of areas between two curves

查看:556
本文介绍了计算两条曲线之间的面积的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个包含曲线和一条线的代码。我知道如何填充下面和下面的区域,但我需要计算每个区域的面积值。

这里是代码:



导入matplotlib.pyplot作为plt

导入numpy为np



x = np.arange(0.0,2,0.01)

y1 = np.sin(2 * np.pi * x)

y2 = 0 * x



< br $> b $ b

fig,ax = plt.subplots(1,1,sharex = True)

ax.plot(x,y1,x,y2) ,color ='black')

ax.fill_between(x,y1,y2,where = y2> = y1,facecolor ='green',interpolate = True)

ax.fill_between(x,y1,y2,where = y2< = y1,facecolor ='red',interpolate = True)

ax.set_title('填充在哪里')





plt.show()



任何帮助?



我尝试了什么:



i试图在谷歌搜索,但我找不到它!!

Hello everyone,
i have a code contain a curve and a line. i know how to fill the areas below and under the line but i need to calculate the areas values of each one.
here is the code:

import matplotlib.pyplot as plt
import numpy as np

x = np.arange(0.0, 2, 0.01)
y1 = np.sin(2*np.pi*x)
y2 = 0*x



fig, ax = plt.subplots(1, 1, sharex=True)
ax.plot(x, y1, x, y2, color='black')
ax.fill_between(x, y1, y2, where=y2 >= y1, facecolor='green', interpolate=True)
ax.fill_between(x, y1, y2, where=y2 <= y1, facecolor='red', interpolate=True)
ax.set_title('fill between where')


plt.show()

any help ?

What I have tried:

i tried searching in Google but i can't find it !!

推荐答案

这是一个数学问题秒。请参阅曲线下的区域 - Google搜索 [ ^ ]。
This is a question of mathematics. See area under a curve - Google Search[^].


这篇关于计算两条曲线之间的面积的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆