matplotlib使用
程序员文章站
2022-03-01 22:16:51
...
import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(-20,20,100)
y=np.cos(x)
fig=plt.figure(figsize=(8,8))
ax1=fig.add_subplot(1,1,1)
ax1.plot(x,y,linestyle='--',color='r',alpha=0.8)
ax1.xlim=([np.min(x)-5,np.max(x)+5])
ax1.ylim=([np.min(y)-0.2,np.max(y)+0.2])
ax1.set_xlabel('test_x',size=20)
ax1.set_ylabel('test_y',rotation=30)
ax1.set_title('Test',size=35)
ax1.grid()
plt.show()
上一篇: matplotlib 使用