import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
def func(x):
return -(x-2)*(x-8)+40
x=np.linspace(0,10)
y=func(x)
fig,ax=plt.subplots()
plt.plot(x,y,‘r’,linewidth=2)
a = 2
b = 9
ax.set_xticks([a,b])
ax.set_yticks([])
ax.set_xticklabels([’aa’,’bb’])
ix=np.linspace(a,b)
iy=func(ix)
ixy=zip(ix,iy)
verts=[(a,0)]+list(ixy)+[(b,0)]
poly=Polygon(verts,facecolor=‘0.9’,edgecolor=‘0.5’)
ax.add_patch(poly)
plt.figtext(0.9,0.05,’xx’)
plt.figtext(0.1,0.9,’yy’)
x_math=(a+b)*0.5
y_math=35
plt.text(x_math,y_math,r’ab((x2)(x8)+40)dx\int_a^b (-(x-2)*(x-8)+40)dx’,
fontsize=20,horizontalalignment=‘center’)
plt.show()
matplotlib函数积分图

相关文章:

  • 2021-11-26
  • 2021-12-31
  • 2021-05-13
  • 2021-04-29
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2021-11-05
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-05
  • 2021-11-27
  • 2021-06-18
  • 2022-02-11
  • 2022-12-23
相关资源
相似解决方案