欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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()
相关标签: 笔记