gnuplot的参数 (new)
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
gnuplot的参数 (new)
有个问题,如果这样调用一脚本的方式。
gnuplot plot.dem 2008
可以把这参数2的那2008带入plot.dem里面作一个变量不。就是要用这参数,来改变图片输出的标题和文件名。
类似这样的
set output "gnuplot-$1.png"
set title "easy-account chart $1"
第2个问题
plot 'chart.dat' using 1:2 with boxes
如果这dat文件缺少了数据,如何设置缺少的数据为0
比如:
01 3.00
03 2.00
04 164.40
少了02的数据。想画02这坐标时,缺省为0。
gnuplot plot.dem 2008
可以把这参数2的那2008带入plot.dem里面作一个变量不。就是要用这参数,来改变图片输出的标题和文件名。
类似这样的
set output "gnuplot-$1.png"
set title "easy-account chart $1"
第2个问题
plot 'chart.dat' using 1:2 with boxes
如果这dat文件缺少了数据,如何设置缺少的数据为0
比如:
01 3.00
03 2.00
04 164.40
少了02的数据。想画02这坐标时,缺省为0。
上次由 eexpress 在 2008-05-13 10:52,总共编辑 1 次。
● 鸣学
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
- roylez
- 帖子: 1928
- 注册时间: 2005-10-04 10:59
- 来自: 上海
现在在家,自己的电脑不在手边。代码可能写得不对,但是意思你应该能够明白。第三个问题应该也一样可以解决。
我比较喜欢用python-gnuplot来调用gnuplot。
或者
我比较喜欢用python-gnuplot来调用gnuplot。
代码: 全选
import Gnuplot
title = sys.argv[1]
g = Gnuplot.gnuplot(persist=1)
g('set output "gnuplot-%s.png" ' %title)
g('set title "easy-account chart %s" ' %title)
代码: 全选
g('''
set output "gnuplot-%s.png"
set title "easy-account chart %s"
''' %(title, title))
-
- 帖子: 1331
- 注册时间: 2006-07-09 12:22
- 来自: 南京
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
- roylez
- 帖子: 1928
- 注册时间: 2005-10-04 10:59
- 来自: 上海
set yrange[:500]
然后用python对数据进行过滤,y>500的地方,加个label不就行了?确实是相当于建立了临时的dem文件,不过方便过写dem文件,毕竟可以在python里面就先对数据进行处理。
我记得gnuplot也可以用变量的。你查查。
http://t16web.lanl.gov/Kawano/gnuplot/index-e.html
然后用python对数据进行过滤,y>500的地方,加个label不就行了?确实是相当于建立了临时的dem文件,不过方便过写dem文件,毕竟可以在python里面就先对数据进行处理。
我记得gnuplot也可以用变量的。你查查。
http://t16web.lanl.gov/Kawano/gnuplot/index-e.html
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
代码: 全选
☎ cat irda.dat
1,0
9,1
4.5,0
# 0
0.56,1
0.56,0
# 1
0.56,1
1.69,0
# 0
0.56,1
0.56,0
# 0
0.56,1
0.56,0
# 1
0.56,1
1.69,0
# 1
0.56,1
1.69,0
# 0
0.56,1
0.56,0
# 1
0.56,1
1.69,0
这是信号采集的数据,其实就是方波。一个宽度带一个0/1表示电平。
另外想,这方波的线,加粗,加蓝色的。
- 附件
-
- 需要产生的样式
- screenshot-2008-05-13-11-33-45.png (3.5 KiB) 查看 3343 次
● 鸣学
- Tenyears
- 帖子: 2245
- 注册时间: 2005-06-30 15:46
- 来自: 成都
- pollothana
- 帖子: 262
- 注册时间: 2007-03-08 10:47
Re: gnuplot的参数 (new)
我来挖个坟,很久没上论坛了,今天正好看到这个问题。
gnuplot -e "year='2008'" plot.dem
in file plot.dem:
gnuplot 4.6 可以,其他版本没注意。
gnuplot -e "year='2008'" plot.dem
in file plot.dem:
代码: 全选
filename=sprintf("gnuplot-%s.png", year)
title=sprintf("easy-account chart %s", year)
set output filename
set title title
My blog: hsquared66.blogspot.com
- pollothana
- 帖子: 262
- 注册时间: 2007-03-08 10:47
Re: gnuplot的参数 (new)
或者也可以这么写:pollothana 写了:我来挖个坟,很久没上论坛了,今天正好看到这个问题。
gnuplot -e "year='2008'" plot.dem
in file plot.dem:gnuplot 4.6 可以,其他版本没注意。代码: 全选
filename=sprintf("gnuplot-%s.png", year) title=sprintf("easy-account chart %s", year) set output filename set title title
代码: 全选
set output "gnuplot-".year.".png"
set title "easy-account chart ".year
My blog: hsquared66.blogspot.com