matplotlib 中fill_between
#有换行,黏贴的文本 plt.fill_between(x,x>0,c,c>0.5,color="green") c,s两个三角函数 到底怎么填充的啊 我觉得如图才对
#下面是代码
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
import numpy as np
import matplotlib.pyplot as plt
plt.title("biao嗯ti")
x=np.linspace(-np.pi,np.pi,256,endpoint=True)
c,s=np.cos(x),np.sin(x)
plt.figure(1)
plt.plot(x,c,label="cos")
plt.plot(x,s,label="sin")
ax=plt.gca()
ax.spines["right"].set_color("none")
ax.spines["top"].set_color("none")
ax.spines["left"].set_position(("data",0))
ax.spines["bottom"].set_position(("data",0))
plt.yticks([1,0.5,0,-0.5,-1])
#plt.xticks([-np.pi,-np.pi/2,0,np.pi/2,np.pi],
# ["-π","π/2","0","π/2","π"])
plt.legend(loc="upper left")
ax.xaxis.set_ticks_position("bottom")
plt.fill_between(x,x>0,c,c>0.5,color="green")
plt.show()