利用 gnuplot 绘制时间序列图 http://blog.csdn.net/liyuanbhu/article/details/8497582
来源:互联网 发布:淘宝网木质沙发 编辑:程序博客网 时间:2024/06/07 05:07
大名鼎鼎的 gnuplot 就不多介绍了。
通常我们利用数据文件绘图时,XY坐标的值都是实数,也就是我们要绘制图形的函数是R到R的映射。可有时横轴或纵轴的数据是时间值,时间的格式每次可能还都不太一样。这时我们就需要特殊设置一下 gnuplot了。
假设我们有数据文件“timedat.dat”,文件的内容如下。
[plain] view plaincopy
#日/月/年 值
01/06/93 100
17/08/93 900
04/10/93 1300
11/10/93 300
28/10/93 1000
可以看到,横坐标是时间值,需要将这个信息告诉gnuplot。利用如下的命令。
[plain] view plaincopy
set xdata time
类似的命令还包括:
[plain] view plaincopy
set ydata time
set zdata time
set x2data time
set y2data time
set cbdata time
如果要回到原来的那种横坐标为数值的状态,可以执行如下命令:
[plain] view plaincopy
set xdata
下面还需要告诉 gnuplot 数据文件中的时间格式是什么样,要利用如下的命令
[plain] view plaincopy
set timefmt "<format string>"
其中format string 用来描述数据文件中时间的格式。对于我们的数据文件,可以这样设置:
[plain] view plaincopy
set timefmt "%d/%m/%y"
Gnuplot 支持的格式如下:
格式
解释
%d
day of the month, 1–31
%m
month of the year, 1–12
%y
year, 0–99
%Y
year, 4-digit
%j
day of the year, 1–365
%H
hour, 0–24
%M
minute, 0–60
%s
seconds since the Unix epoch (1970-01-01 00:00 UTC)
%S
second, integer 0–60 on output, (double) on input
%b
three-character abbreviation of the name of the month
%B
name of the month
到这里就设置好了,下面开始显示
[plain] view plaincopy
plot 'timedat.dat' using 1:2 with points ps 3 pt 6 title ""
输出的图形如下。
可以看到输出的横坐标只有月份和日期,没有年份信息。如果需要加入年份信息,可以这样设置:
[plain] view plaincopy
set format x "%y/%m/%d"
然后更新一下输出:
[plain] view plaincopy
Replot
通常我们利用数据文件绘图时,XY坐标的值都是实数,也就是我们要绘制图形的函数是R到R的映射。可有时横轴或纵轴的数据是时间值,时间的格式每次可能还都不太一样。这时我们就需要特殊设置一下 gnuplot了。
假设我们有数据文件“timedat.dat”,文件的内容如下。
[plain] view plaincopy
#日/月/年 值
01/06/93 100
17/08/93 900
04/10/93 1300
11/10/93 300
28/10/93 1000
可以看到,横坐标是时间值,需要将这个信息告诉gnuplot。利用如下的命令。
[plain] view plaincopy
set xdata time
类似的命令还包括:
[plain] view plaincopy
set ydata time
set zdata time
set x2data time
set y2data time
set cbdata time
如果要回到原来的那种横坐标为数值的状态,可以执行如下命令:
[plain] view plaincopy
set xdata
下面还需要告诉 gnuplot 数据文件中的时间格式是什么样,要利用如下的命令
[plain] view plaincopy
set timefmt "<format string>"
其中format string 用来描述数据文件中时间的格式。对于我们的数据文件,可以这样设置:
[plain] view plaincopy
set timefmt "%d/%m/%y"
Gnuplot 支持的格式如下:
格式
解释
%d
day of the month, 1–31
%m
month of the year, 1–12
%y
year, 0–99
%Y
year, 4-digit
%j
day of the year, 1–365
%H
hour, 0–24
%M
minute, 0–60
%s
seconds since the Unix epoch (1970-01-01 00:00 UTC)
%S
second, integer 0–60 on output, (double) on input
%b
three-character abbreviation of the name of the month
%B
name of the month
到这里就设置好了,下面开始显示
[plain] view plaincopy
plot 'timedat.dat' using 1:2 with points ps 3 pt 6 title ""
输出的图形如下。
可以看到输出的横坐标只有月份和日期,没有年份信息。如果需要加入年份信息,可以这样设置:
[plain] view plaincopy
set format x "%y/%m/%d"
然后更新一下输出:
[plain] view plaincopy
Replot
这时的输出结果就满足我们的需求了。如果需要更细致的设置,请参考 gnuplot 的帮助文件。
http://blog.sina.com.cn/s/blog_66de158f0100humj.html --另一个画图软件
0 0
- 利用 gnuplot 绘制时间序列图 http://blog.csdn.net/liyuanbhu/article/details/8497582
- http://blog.csdn.net/l_ch_g/article/details/8217725 时间日期
- C++中的srand(time(null))利用时间设置随机种子产生随机数 http://blog.csdn.net/youoran/article/details/10950671
- 利用 gnuplot 绘制时间序列图
- AS3:时间戳的转换 http://blog.csdn.net/a7719665/article/details/5912004#
- 时间复杂度和空间复杂度详解 http://blog.csdn.net/booirror/article/details/7707551
- http://blog.csdn.net/IBM_hoojo/article/details/5688947
- http://blog.csdn.net/chenlaic/article/details/6143235
- http://blog.csdn.net/eaglewood2005/article/details/4335052
- http://blog.csdn.net/mchp/article/details/3995970
- http://blog.csdn.net/v_july_v/article/details/6015165
- http://blog.csdn.net/masterz/article/details/6232585
- http://blog.csdn.net/perfectpdl/article/details/6442847
- http://blog.csdn.net/eroswang/article/details/1967243
- http://blog.csdn.net/zhvsby/article/details/5986645
- http://blog.csdn.net/dz45693/article/details/6183645
- http://blog.csdn.net/david_lv/article/details/5798003
- http://blog.csdn.net/zxingchao2009/article/details/6299313
- Android典型界面设计(5)——使用SlidingMenu和DrawerLayout分别实现左右侧边栏
- IDW插值服务
- poj 2796
- objective-C中没有"接口"与"泛型"这样的说法,但有正式协议protocal 和 一种特殊的指针id类型
- Solr Cache使用介绍及分析
- 利用 gnuplot 绘制时间序列图 http://blog.csdn.net/liyuanbhu/article/details/8497582
- JPA对应的数据库字段大小写问题
- Android Studio写Android代码时Java文件实现Eclipse包浏览效果
- poj 2774 Long Long Message 后缀数组
- hdu 5364 Distribution money 简单题
- asp.net中AngularJS+ashx的使用
- mysql优化,提高命中率
- JNDI(2)
- GET与POST传输的区别