matplotlib画子图

2018-04-25  本文已影响0人  德先森的书

import numpy as np

fig = plt.figure()

fig = plt.figure(figsize=(3, 3)) #设置图片大小

fig.add_subplot(a,b,c) a行b列的,c代表位置

ax1 = fig.add_subplot(2,1,1) #2行1列的第一个图
ax2 = fig.add_subplot(2,1,2) #2行1列的第二个图

作图

ax1.plot(np.random.randint(1,5,5), np.arange(5),c="red")
ax2.plot(np.arange(10)*3, np.arange(10),c="green")
plt.show()


untitled.png
上一篇下一篇

猜你喜欢

热点阅读