为什么运行后我的标题和修改后的坐标轴在一个图上,而正余弦曲线在另一个图上(还是最开始的样子)?
import matplotlib.pyplot as plt 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,color="blue",linewidth=1.0,linestyle="-",label="COS",alpha=0.5) plt.plot(x,s,"r*",label="SIN") plt.show() plt.title("COS & 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.show()