使用matplot绘图 @python
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的更多相关文章
- python matplot 绘图
import numpy as np import matplotlib.pyplot as plt plt.figure(1) # 创建图表1 plt.figure(2) # 创建图表2 ax1 = ...
- Turtle绘图——python简单上手小案例
Turtle绘图 Turtle模块提供了在二维平面上移动的环境. Turtle可以实现位置.航向和各种可能的状态和动作. import turtle as tu roo = tu.Turtle() # ...
- 获取博客积分排名,存入数据库,读取数据进行绘图(python,selenium,matplotlib)
该脚本的目的:获取博客的排名和积分,将抓取时间,排名,积分存入数据库,然后把最近的积分和排名信息进行绘图,查看积分或者排名的变化情况. 整个脚本的流程:是利用python3来编写,利用selnium获 ...
- matplot绘图基本使用
先看一个最简单的例子 import matplotlib.pyplot as plt plt.figure() plt.subplot(211) plt.plot([1,2,3], color=''r ...
- matplot绘图
import matplotlib.pyplot as pltimport numpy as npimport matplotlib # 设置matplotlib正常显示中文和负号matplotlib ...
- matplot绘图(五)
b3D图形绘制 # 导包:from mpl_toolkits.mplot3d.axes3d import Axes3Dimport matplotlib.pyplot as plt%matplotli ...
- matplot绘图无法显示中文的问题
手动添加: from pylab import * mpl.rcParams['font.sans-serif'] = ['SimHei'] #指定默认字体 mpl.rcParams['axes.un ...
- 计算机辅助数据绘图(matlab\python\js)
1. matlab绘图 官方说明:https://ww2.mathworks.cn/help/matlab/creating_plots/types-of-matlab-plots.html 基本图形 ...
- 用python一步一步教你玩微信小程序【跳一跳】
12月28日,微信上线了小游戏「跳一跳」,瞬间成了全民游戏,如何牢牢占据排行榜的第一位呢?用Python帮助你,Python真的无所不能. 作为技术出身的我们,是不是想用技术改变排名呢? 注意:本文适 ...
随机推荐
- Html-双斜杠//开头的URL(依赖协议的URL)
今天看京东HTTPS,发现链接都是这种 <a href="//chaoshi.jd.com">京东超市</a> URL是以双斜杠"//" ...
- LNMP-查看安装编译时参数
查看mysql编译参数: cat /usr/local/mysql/bin/mysqlbug | grep CONFIGURE_LINE 查看apache编译参数: cat $apachehome$/ ...
- premiere视频输出参数设置
- webbrowser在不同的.netframework版本差异
这几在做一个浏览器的自动化下载的工具,发现自己做的demo和做的项目代码运行不一致,代码就那么几行,拷贝过去为什么有些行为就不一样呢?经过分析发现原来有.net4.0和.net2.0中的webbrow ...
- maxscript,#号和$号
一,#号: 1,数组 #(123, "hi") 2,系统目录 fileName = getDir #scripts + "\\xxx.ms" 二,$号 节点路径 ...
- .net 实现 URL重写,伪静态(方法一)
一,获得Mircosoft URLRewriter.dll(注意:此dll文件大小约为20KB,网上有8Kb的是不完整的文件,会报错) 二,在项目中该dll文件:添加引用(可以直接拷贝放入Bin文件夹 ...
- DataList与Repeater嵌套绑定
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="home.aspx.cs&quo ...
- FastJson的基本用法----转
1. [文件] User.java ~ 243B 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 class User{ private int id; ...
- Android 网络编程 Socket
1.服务端开发 创建一个Java程序 public class MyServer { // 定义保存所有的Socket,与客户端建立连接得到一个Socket public static List< ...
- [spring security] spring security 4 基础Demo
依赖包: <properties> <junit.version>4.11</junit.version> <spring.version>4.1.6. ...