matplotlib:多个图表的绘制
使用subplot
实现,用于生成一个子图,参数为行、列、索引
import matplotlib.pyplot as pltmonth = ['1','2','3','4']
sales = [100,150,80,130]f1 = plt.subplot(2,2,1)
# 也可以简写 f1 = plt.subplot(221)f1.plot(month,sales)f2 = plt.subplot(2,2,2)
f2.bar(month,sales)f3 = plt.subplot(2,2,3)
f3.scatter(month,sales)f4 = plt.subplot(2,2,4)
f4.barh(month,sales)