数据分析~matplotlib.pyplot画布、画图

import numpy as np
import matplotlib.pyplot as plt
#视图 x\y等分越细致,画图越细致
x=np.arange(-100,100,1)
y=np.arange(-80,80,1)
x,y=np.meshgrid(x,y)
z=np.sqrt(x**2+y**2)
#画图
#1、创建画布
fig=plt.figure()

#分画框,两行两列,标注画框号,1,2,3,4
#编号从左到右,从上到下
ax=fig.add_subplot(221)
ax.imshow(z)

ax=fig.add_subplot(222)
ax.imshow(z,cmap=plt.cm.gray)

ax=fig.add_subplot(223)
ax.imshow(z,cmap=plt.cm.cool)

ax=fig.add_subplot(224)
ax.imshow(z,cmap=plt.cm.hot)
plt.show()
 
 

猜你喜欢

转载自blog.csdn.net/zbrj12345/article/details/80690828