Draw Line and Bar Chart with Matplotlib 画线和图表
来源:互联网 发布:jquery遍历json集合 编辑:程序博客网 时间:2024/06/03 01:45
做了实验以后,一般需要用图形说明数据的含义,我常用简单的曲线图,和柱状图。
我之前只会用Excel,但是Excel画出来的图总感觉不够专业,在看师弟的presentation的时候,看到他的图画的真漂亮,原来是用matplotlib画出来的。
matplotlib用python画图,简单,专业。
曲线图:
from pylab import * x = [1000,2000,3000,4000,5000] y1 = [0.011953034,0.007304378,0.005531108,0.004629965,0.004060263] y2 = [0.035454429,0.022320288,0.01772984,0.015249259,0.01372336] y3 = [0.026161949,0.016665585,0.012492591,0.010455093,0.009240063] plot ( x,y1,'-*',label='p(a11)' ) plot ( x,y2,'-.',label='p(a15)' ) plot ( x,y3,'-^',label='p(a9)' ) xlabel('Query Cost') ylabel('Relative Error') title('') legend(('p(a11)','p(a15)', 'p(a9)' )) savefig("12.eps",dpi=(640/8))
柱状图:
from pylab import * import numpy as np import matplotlib.pyplot as plt N = 10 ind = np.arange(N) # the x locations for the groups real = (0.002347311,0.746810124,0.010814069,0.105738581,0.001854101,0.0106588,0.002365578,0.007982683,0.003616868,0.00516043) width = 0.35 # the width of the bars fig = plt.figure() ax = fig.add_subplot(111) rects1 = ax.bar(ind, real, width, color='r') estimate = (0.002356675,0.75296556,0.010905585,0.107045611,0.001877654,0.017312228,0.004060263,0.01372336,0.006420114,0.009240063) rects2 = ax.bar(ind+width, estimate, width, color='y') # add some ax.set_ylabel('p(ai)') ax.set_xticks(ind+width) ax.set_xticklabels( ('a32', 'a19', 'a65', 'a40', 'a68','a10', 'a11', 'a15', 'a20', 'a9') ) ax.legend( (rects1[0], rects2[0]), ('real-p(ai)', 'estimate-p(ai)') ) savefig("11.eps",dpi=(640/8))
参考资料:
matplotlib使用小结(基本篇):http://flyfeeling.blogbus.com/logs/53148228.html
matplotlib主页:http://matplotlib.org/
0 0
- Draw Line and Bar Chart with Matplotlib 画线和图表
- C# 画线 Draw a Line
- Draw Picture With Python Matplotlib
- XCL-Charts画线图(Line Chart)
- CG : Draw Line And Draw Circle
- Android Line Bar Pie Graph图表
- echarts+ajax+restful实现图表(bar/line)
- Matplotlib - bar,scatter and histogram plots
- simple line chart , scatter diagram and RandomWalk
- Extjs学习 图表Chart 复合图表 和 图表与表格
- Draw Line
- Draw Line
- Chart图表
- Chart图表
- Chart图表
- Chart FX for JAVA (2)--------Lines AND Bar
- Customizing chart bar color. Make the bar can filld with picture.
- Scrolling and zooming chart with ChartScroller
- Cannot open include file: 'ntddndis.h': No such file or directory
- 大规模分布式系统架构与设计实战
- ZK示例
- 你总是会这样那样的受伤,有时候很痛
- 银行业务调度系统
- Draw Line and Bar Chart with Matplotlib 画线和图表
- 滚动条原理分析(在使用纯C + API画列表及列表的滚动条时遇到的问题)
- 笔试面试(4)百度2014软件开发工程师笔试题详解
- flex 身份证验证
- cocos3D 初体验
- 通过td获取其父节点的id
- 计算机4级网络攻城尸笔记
- 心理学导论(第9版)笔记 第一章 心理学是什么?
- C Primer Plus汇总