1. 使用csv 模块读取数据

2. 定义label

3. 绘图,调参

#!/usr/bin/env python
# coding=utf-8 import sys
import matplotlib.pyplot as plt
import xlrd
import csv
from datetime import datetime reload(sys)
sys.setdefaultencoding('utf-8') def load_data(fname='./data.xlsx'):
wb = xlrd.open_workbook(fname)
print wb.sheet_names()
sheet =wb.sheet_by_index(0)
res = []
for i in range(1,7): #选取6行
rows = sheet.row_values(i)
print 'i',rows
res.append(map(float,rows.split()))
return res def load_data2(fname='./data.csv'):
reader = csv.reader(open(fname))
res = []
for line in reader:
if reader.line_num == 1:
continue
res.append(line)
return res def floatrange(start,stop,steps):
return [start+float(i)*(stop-start)/(float(steps)-1) for i in range(steps)] def draw_picture(data=[],label=[]):
x = map(lambda x:0.1*x,range(-12,14,2)) fig = plt.figure()
ax = fig.add_subplot(111)
for i in range(len(data)):
ax.plot(x,data[i],label=label[i],linewidth=1.5) datestr = datetime.now().strftime('%Y-%m-%d')
ax.set_title('draw_picture demo\n\n%s\n'%(datestr))
ax.legend()
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_xlim(-1.3,1.3,0.2)
plt.show() data = load_data2()
label = ['line1','line2','c','d','e','f']
draw_picture(data,label)

使用matplot绘图 @python的更多相关文章

  1. python matplot 绘图

    import numpy as np import matplotlib.pyplot as plt plt.figure(1) # 创建图表1 plt.figure(2) # 创建图表2 ax1 = ...

  2. Turtle绘图——python简单上手小案例

    Turtle绘图 Turtle模块提供了在二维平面上移动的环境. Turtle可以实现位置.航向和各种可能的状态和动作. import turtle as tu roo = tu.Turtle() # ...

  3. 获取博客积分排名,存入数据库,读取数据进行绘图(python,selenium,matplotlib)

    该脚本的目的:获取博客的排名和积分,将抓取时间,排名,积分存入数据库,然后把最近的积分和排名信息进行绘图,查看积分或者排名的变化情况. 整个脚本的流程:是利用python3来编写,利用selnium获 ...

  4. matplot绘图基本使用

    先看一个最简单的例子 import matplotlib.pyplot as plt plt.figure() plt.subplot(211) plt.plot([1,2,3], color=''r ...

  5. matplot绘图

    import matplotlib.pyplot as pltimport numpy as npimport matplotlib # 设置matplotlib正常显示中文和负号matplotlib ...

  6. matplot绘图(五)

    b3D图形绘制 # 导包:from mpl_toolkits.mplot3d.axes3d import Axes3Dimport matplotlib.pyplot as plt%matplotli ...

  7. matplot绘图无法显示中文的问题

    手动添加: from pylab import * mpl.rcParams['font.sans-serif'] = ['SimHei'] #指定默认字体 mpl.rcParams['axes.un ...

  8. 计算机辅助数据绘图(matlab\python\js)

    1. matlab绘图 官方说明:https://ww2.mathworks.cn/help/matlab/creating_plots/types-of-matlab-plots.html 基本图形 ...

  9. 用python一步一步教你玩微信小程序【跳一跳】

    12月28日,微信上线了小游戏「跳一跳」,瞬间成了全民游戏,如何牢牢占据排行榜的第一位呢?用Python帮助你,Python真的无所不能. 作为技术出身的我们,是不是想用技术改变排名呢? 注意:本文适 ...

随机推荐

  1. dede留言板链接变成localhost的解决办法

    去前缀arctype表中找到在线留言栏 把根目录换成{cmspath}/ 例如{cmspath}/plus/guestbook.php 或者在后台的栏目管理里改---但是预览不能使用了

  2. 异构平台同步(Mysql到Oracle)

    Oracle GoldenGate学习之--异构平台同步(MySQL到Oracle) 如图所示:源端采用Mysql库,目标端采用Oracle库 一.OGG安装配置(源端) 1.OGG下载 https: ...

  3. C# typeof()实例详解

    typeof(C# 参考) 用于获取类型的 System.Type 对象.typeof 表达式采用以下形式: System.Type type = typeof(int);  备注 若要获取表达式的运 ...

  4. ASP.NET MVC报错: Multiple types were found that match the controller named

    当使用ASP.NET MVC的Area功能时,出现了这样的错误: Multiple types were found that match the controller named 'Home'. T ...

  5. Visual Studio 文件没发布出来

    解决办法是选择文件打开属性窗口找到生成操作,选项选择"内容",重新发布,OK,问题解决.

  6. Redis分布式部署,一致性hash

    一致性哈希 由于hash算法结果一般为unsigned int型,因此对于hash函数的结果应该均匀分布在[0,2^32-1]区间,如果我们把一个圆环用2^32 个点来进行均匀切割,首先按照hash( ...

  7. ASP.NET MVC 页面调整并传递参数

    转自:http://blog.csdn.net/zhensoft163/article/details/7174661 使用过ASP.NET MVC的人都知道在MVC中页面后台中常用的页面跳转方法有几 ...

  8. collection的框架结构

    经常会看到程序中使用了记录集,常用的有Collection.HashMap.HashSet.ArrayList,因为分不清楚它们之间的关系,所以在使用时经常会混淆,以至于不知道从何下手.在这儿作了一个 ...

  9. Jaxb笔记

    摘自: http://www.blogjava.net/eagle-daiq/archive/2012/01/30/369016.html 最近项目原因,研究了下jaxb.jaxb是Java api ...

  10. 程序员书单_J2EE专题

    Enterprise JavaBeans 3.0中文版(第5版) http://download.csdn.net/detail/shenzhq1980/9104015 J2EE设计模式 http:/ ...