Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1663179
  • 博文数量: 230
  • 博客积分: 10045
  • 博客等级: 上将
  • 技术积分: 3357
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-30 20:40
文章分类

全部博文(230)

文章存档

2011年(7)

2010年(35)

2009年(62)

2008年(126)

我的朋友

分类:

2010-03-22 17:01:26

使用gnuplot从数据文件中创建图表
之前Windows XP下离线计算宽带上网时间(perl实现)搞了一个自己用的统计上网时间的程序,正好用gnuplot试试从统计结果中创建图形。

统计数据如下:
2009-2 : 2:53:24
2009-3 : 38:35:56
2009-4 : 33:8:3
2009-5 : 21:54:25
2009-6 : 33:59:16
2009-7 : 38:9:25
2009-8 : 24:53:48
2009-9 : 31:50:53
2009-10 : 35:18:38
2009-11 : 25:40:56
2009-12 : 28:46:58
2010-1 : 22:10:5
2010-2 : 28:27:1
2010-3 : 28:18:52

用gnuplot编写的脚本创建图形如下:

脚本代码如下:(data.gp)

##############################################
##  gnuplot example -- 绘制上网时间统计图
##  bilbo
##  2010年3月22日
##############################################

set datafile separator ":"

##############################################
##  2D图名称
##############################################
set title "宽带上网时间统计" offset 0,-1

##############################################
##  x轴显示定义
##############################################
set xlabel "日期" offset 0, -1
set xdata time
set timefmt "%Y-%m"
set format x "%b\n %Y"
set xrange ["2009-1":"2010-4"]
set xtics "2009-1", 60*60*24*28, "2010-4"
set mxtics 1

##############################################
##  y轴显示定义
##############################################
set ylabel "累计时间(小时)"
set format y "%.0f"
set yrange ["0":"45"]
set ytics "0", 5, "45"
set mytics 2

##############################################
##  绘制图形
##############################################
plot 'data.txt' using 1:(($2*60*60 + $3*60 + $4)/3600) title "上网时间" \
with impulses linecolor rgb "blue" linewidth 8


在gnuplot或wgnuplot中输入load 'data.gp'即可。
阅读(1541) | 评论(0) | 转发(0) |
0

上一篇:use gnuplot(1)

下一篇:use gnuplot(3)

给主人留下些什么吧!~~