python的绘图工具matplotlib使用实例
2014-07-03 00:00
1216 查看
matplotlib是功能十分强大的绘制二维图形的Python模块,它用Python语言实现了MATLAB画图函数的易用性,同时又有非常强大的可定制性。它提供了一整套和matlab相似的命令API,十分适合交互式地进行制图。而且也可以方便地将它作为绘图控件,嵌入GUI应用程序中。它的文档相当完备,并且Gallery页面中有上百幅缩略图,打开之后都有源程序。因此如果你需要绘制某种类型的图,只需要在这个页面中浏览、复制、粘贴一下,基本上都能搞定!
实例代码如下:
1. 柱状图
运行效果如下:
2. 饼形图
运行效果如下:
实例代码如下:
1. 柱状图
import matplotlib.pyplot as plt plt.bar(left = 0,height = 1) plt.show()
运行效果如下:
2. 饼形图
#! coding: cp936 from pylab import * # make a square figure and axes figure(1, figsize=(6,6)) ax = axes([0.1, 0.1, 0.8, 0.8]) fracs = [45, 30, 25] #每一块占得比例,总和为100 explode=(0, 0, 0.08) #离开整体的距离,看效果 labels = 'Hogs', 'Dogs', 'Logs' #对应每一块的标志 pie(fracs, explode=explode, labels=labels, autopct='%1.1f%%', shadow=True, startangle=90, colors = ("g", "r", "y")) # startangle是开始的角度,默认为0,从这里开始按逆时针方向依次展开 title('Raining Hogs and Dogs') #标题 show()
运行效果如下:
相关文章推荐
- python的绘图工具matplotlib使用实例
- 按钮实现Python--绘图工具matplotlib的使用
- Python--绘图工具matplotlib的使用
- Python绘图和数值工具:matplotlib 和 numpy下载与使用
- Python绘图和数值工具:matplotlib 和 numpy下载与使用
- python绘图工具matplotlib在linux下安装和使用
- 安装python Matplotlib 库绘图工具流程
- 使用 python Matplotlib 库绘图
- python使用matplotlib绘图 -- barChart
- python使用matplotlib 以及matplotlib安装绘图(window7)
- 使用 python Matplotlib 库绘图
- python 绘图工具 matplotlib 入门
- 使用 python Matplotlib 库绘图
- 使用 python Matplotlib 库绘图
- 使用 python Matplotlib 库绘图
- python使用matplotlib绘图 -- barChart
- Python开发环境Wing IDE使用教程之matplotlib 2D绘图库代码调试技巧
- 使用 python Matplotlib 库绘图
- python使用matplotlib绘图 -- barChart
- python使用matplotlib绘图 -- barChart