Python+matplotlib+numpy绘制精美的条形统计图
2018-01-02 10:38
1426 查看
本文实例主要向大家分享了一个Python+matplotlib+numpy绘制精美的条形统计图的代码,效果展示如下:
完整代码如下:
import matplotlib.pyplot as plt from numpy import arange from numpy.random import rand def gbar(ax, x, y, width=0.5, bottom=0): X = [[.6, .6], [.7, .7]] for left, top in zip(x, y): right = left + width ax.imshow(X, interpolation='bicubic', cmap=plt.cm.Blues, extent=(left, right, bottom, top), alpha=1) fig = plt.figure() xmin, xmax = xlim = 0, 10 ymin, ymax = ylim = 0, 1 ax = fig.add_subplot(111, xlim=xlim, ylim=ylim, autoscale_on=False) X = [[.6, .6], [.7, .7]] ax.imshow(X, interpolation='bicubic', cmap=plt.cm.copper, extent=(xmin, xmax, ymin, ymax), alpha=1) N = 10 x = arange(N) + 0.25 y = rand(N) gbar(ax, x, y, width=0.7) ax.set_aspect('auto') plt.show()
总结
以上就是本文关于Python+matplotlib+numpy绘制精美的条形统计图的全部内容,希望对大家有所帮助。感兴趣的朋友可以继续参阅本站其他相关专题,如有不足之处,欢迎留言指出。感谢朋友们对本站的支持!
您可能感兴趣的文章:
相关文章推荐
- python 使用numpy matplotlib绘制图表
- 【数据可视化】Daft:(Python)基于matplotlib绘制精美概率图模型
- python: matplotlib-绘制精美的图表
- matplotlib绘制精美的图表(这是教程哦)
- python+matplotlib绘制简单的海豚(顶点和节点的操作)
- matplotlib-绘制精美的图表
- python中Matplotlib实现绘制3D图的示例代码
- Python搭建Numpy、SciPy、MatPlotLib环境(下载、安装、测试)
- 利用matplotlib在python上绘制3D散点图
- python matplotlib 方程的绘制
- python安装numpy、scipy和matplotlib等whl包的方法
- Windows7-64位python2.7、NumPy以及matplotlib的安装
- Python 2.7(3.x)以及numpy、matplotlib和scipy库三种方法实战安装
- Convolution卷积算法python以numpy,Matplotlib实现
- 使用python matplotlib绘制简单图形
- numpy和matplotlib绘制直方图
- Windows系统中安装Python模块pip numpy matplotlib
- Python使用matplotlib模块绘制图像并设置标题与坐标轴等信息示例
- Python绘图和数值工具:matplotlib 和 numpy下载与使用
- 在Ubuntu Linux 安装Python第三方库:NumPy,SciPy,Matplotlib, Scikit-Learn,Theao等