Python之matplotlib
2015-04-24 14:32
274 查看
matplotlib是python的一个绘图库,命令与matlab很像。
具体的用法可以参照 http://www.cnblogs.com/qianlifeng/archive/2012/02/13/2350086.html
使用元组可以表示多个矩形
width=0.3 用来设置矩形的宽度, align='center'使矩形居中
plt.xticks((0,2),('M','W')) 给每个矩形块具体的文字说明
plt.legend((rect,),('legend',))用来添加图例
autolabel(rect)是一个自定义的函数,用来实现每个矩阵块上写上它的值.
plt.bar()是条形图
其他几种常见图比如
复制去Google翻译翻译结果
具体的用法可以参照 http://www.cnblogs.com/qianlifeng/archive/2012/02/13/2350086.html
import matplotlib.pyplot as plt plt.bar(left=0,height=1) plt.show()
使用元组可以表示多个矩形
plt.bar(left=(0,2),height=(1,0.4)) #用元组表示多个矩形 plt.show()
def autolabel(rects): for rect in rects: height = rect.get_height() plt.text(rect.get_x()+rect.get_width()/2.,1.03*height,'%s' % float(height)); rect=plt.bar(left=(0,2),height=(1,0.4) ,width=0.3, align='center') #width用来设置矩形宽度 plt.xlabel(u'性别') plt.ylabel(u'人数') #中文一定要加u,因为matplotlib只支持unicode.但我的电脑依旧乱码 plt.xticks((0,2),('M','W')) #前面添加的align='center'属性使矩形居中了,与文字对齐 plt.title('Anaysis of China') plt.legend((rect,),('legend',)) autolabel(rect) plt.show()
width=0.3 用来设置矩形的宽度, align='center'使矩形居中
plt.xticks((0,2),('M','W')) 给每个矩形块具体的文字说明
plt.legend((rect,),('legend',))用来添加图例
autolabel(rect)是一个自定义的函数,用来实现每个矩阵块上写上它的值.
plt.bar()是条形图
其他几种常见图比如
x=(1,2,3,4,5,6) y=(2,2,4,7,9,1) plt.scatter(x,y) plt.show()
x=(1,2,3,4,5,6) y=(2,2,4,7,9,1) plt.plot(x,y) plt.show()
复制去Google翻译翻译结果
相关文章推荐
- [置顶] Python数据可视化—matplotlib笔记
- Python数据可视化matplotlib(二)—— 子图功能
- python matplotlib绘图时图例显示问题
- python3使用matplotlib画图支持中文
- python Numpy,SciPy,MatplotLib,pandas安装流程
- win7 安装openCV Python 与 Numpy,Scipy,Matplotlib,Scikit-Learn包
- <Python>Numpy和Matplotlib的HelloWorld
- Python画图matplotlib展示图中中文乱码
- Python-Matplotlib(4) 直方图与四分图
- python绘图——matplotlib,seaborn,plotly
- CentOS中python输入import matplotlib.pyplot提示有错误
- Python中用matplotlib.pyplot画图总结
- python networkx numpy scipy matplotlib 安装
- Python 数据分析之matplotlib
- 按钮实现Python--绘图工具matplotlib的使用
- Python数据分析与挖掘实战(Pandas,Matplotlib常用方法)
- python2.7 pip 安装Numpy matplotlib
- 【python】matplotlib在windows10 和win7下安装
- 04_1Python绘图_matplotlib
- python用matplotlib画图例子(3)