1.python填充颜色的交叉曲线
2.代码例子
曲线用sin进行编写 根据sin和cos的值进行填充
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
font_set = FontProperties(fname='/Library/Fonts/Songti.ttc', size=15)
x=np.linspace(0,3,500)
y1=np.sin(2*np.pi*x)
y2=1.1*np.sin(3*np.pi*x)
y3=np.cos(3*np.pi*x)
fig,ax=plt.subplots(6,1,sharex="all")
# y2 and 0
ax[0].fill_between(x,0, y2,alpha=0.5)
ax[0].set_ylim(-1.2,1.2)
# y2 and 1.1
ax[1].fill_between(x,y2,1.1,alpha=0.5)
ax[1].set_ylim(-1.2,1.2)
# y1 and y2
ax[2].fill_between(x,y1,y2,alpha=0.5)
ax[2].set_ylim(-1.2,1.2)
ax[2].set_xlim(0,2)
# y2 and 0.5
ax[3].fill_between(x,0.5, y2,alpha=0.5)
ax[3].set_ylim(-1.2,1.2)
# y2*1.5 and 0
ax[4].fill_between(x,0, y2*1.5,alpha=0.5)
ax[4].set_ylim(-2.5,2.5)
# y3 and y2
ax[5].fill_between(x,y2, y3,alpha=0.5)
ax[5].set_ylim(-1.2,1.2)
plt.show()
3.运行效果
原文链接:https://blog.csdn.net/keny88888/article/details/105134070