import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-1,1,50)
y1=x**2
y2=2*x+1
#第一个绘图框
plt.figure()
plt.plot(x,y1)
#第二个绘图框
plt.figure(num=3,figsize=(8,5))
plt.plot(x,y2)
plt.plot(x,y1,color="red",linewidth=1.0,linestyle="--")
plt.show()
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-1,1,50)
y1=x**2
y2=2*x+1
plt.figure(num=3,figsize=(8,5))
plt.plot(x,y2)
plt.plot(x,y1,color="red",linewidth=1.0,linestyle="--")
#控制xy轴的数值范围
plt.xlim(-1,2)
plt.ylim(-3,3)
#x,y轴的标签
plt.xlabel("i am x")
plt.ylabel("i am y")
#更改x轴的数字标签
new_ticks=np.linspace(-1,2,5)
plt.xticks(new_ticks)
#更改y轴的数字标签(r是转义字符)
plt.yticks([-2,-1.8,-1,-1.22,-3,],
[r"$really\ good\ \alpha$","normal","good","very good","nice"])
plt.show()
Copyright ©2011-2014 bbs.06climate.com All Rights Reserved. Powered by Discuz! (京ICP-10201084)
本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论