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()
已解决,中间多输了一次plt.show()