两条正线函数的曲线中填充颜色
直接贴代码了
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(0,4*np.pi,0.0001)
y1 = np.sin(x)
y2 = np.sin(x*2)
plt.plot(x,y1,color='blue')
plt.plot(x,y2,color='red')
plt.show()
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(0,4*np.pi,0.0001)
y1 = np.sin(x)
y2 = np.sin(x*2)
plt.fill_between(x,y1,y2,where=(y1>y2)&(y2>y1)|(x>0),facecolor='purple')
plt.show()
这只是快速掌握画图小技巧,要画出好的还是的继续学习
这里有个小问题,我还没有解决方法
import matplotlib.pyplot as plt
import numpy as np
x1 = np.arange(0,4*np.pi,0.0001)
x2 = x1*2
y1 = np.sin(x1)
y2 = np.sin(x2)
plt.plot(x1,y1,color='blue')
plt.plot(x2,y2,color='red')
plt.show()
当自变量没有共用时(即用x1和x2来标识),那么在输出的时候两个曲线的时候是分开输出的,曲线没有在同一个画布上
等我解决了再来更新