#!/usr/bin/env python # -*- coding:utf-8 -*- from matplotlib.pyplot import * x=[1,2,3,4] y=[5,4,3,2] # 创建新图标 figure() # 对角线图 第1个参数:2行 第2个参数:3列的网格 第3个参数:图形在网格的位置 subplot(231) plot(x,y) # 垂直柱状图 subplot(232) bar(x,y) # 水平柱状图 subplot(233) barh(x,y) # 堆叠柱状图-颜色间隔 subplot(234) bar(x,y) y1=[7,8,5,3] bar(x,y1,bottom=y,color='r') # 箱线图 subplot(235) boxplot(x) # 散点图 subplot(236) scatter(x,y) show() # 箱线图-柱状图 dataset=[113,115,119,121,124,124,125,126,126,127,127,128,129,130,130,131,132,133,136] subplot(121) boxplot(dataset,vert=False) subplot(122) hist(dataset) show()