Chinaunix首页 | 论坛 | 博客
  • 博客访问: 461983
  • 博文数量: 115
  • 博客积分: 3777
  • 博客等级: 中校
  • 技术积分: 1070
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-07 09:20
文章分类

全部博文(115)

文章存档

2015年(1)

2013年(3)

2012年(26)

2011年(30)

2010年(34)

2009年(21)

我的朋友

分类: LINUX

2011-05-03 21:48:27



plot 命令的格式:
Syntax:
plot {[ranges]}
{[function] | {"[datafile]"
{datafile-modifiers}}}
{axes [axes] } { [title-spec] } {with [style] }
{, {definitions,} [function] ...}

plot 一个数据文件。 例子文件 a.txt 的内容的一部分。

1 611738 581056 593414 583590 502984 553813
2 661569 548566 556251 503663 461451 507295
3 723006 558036 518351 461444 429248 464006
4 748299 579828 510268 432925 403245 444233
5 770639 630340 558121 428781 409407 447517
6 773501 663703 580150 430565 414668 454168
7 773358 680100 602547 429561 415999 459455
8 772250 693620 616986 424956 416455 461635
9 767792 714011 642304 419132 413608 464747
10 760577 729287 666633 410204 416556 464428
...

gnuplot> plot "data.txt" using 1:2

using 1:2 表示用第一列表示 x 坐标,用第二列表示 y 坐标。

gnuplot> plot [0:100] [0:800000] "a.txt" using 1:2

可以指明 x 坐标的范围是 0 到 100 , y 坐标的范围是 0 到 800000 。下面的办法一样可以实现相同的功能。

gnuplot> set xrange [0:100]
gnuplot> set yrange [0:800000]
gnuplot> plot "a.txt" using 1:2

可以用 title 来指明一个曲线的名字。

gnuplot> plot "a.txt" using 1:2 title "sample curve" ;

可以用

gnuplot> plot "a.txt" using 1:2 with lines # 用线条画图
gnuplot> plot "a.txt" using 1:2 with points # 用点画图
gnuplot> plot "a.txt" using 1:2 with linespoints # 用点线结合的方式画图

下面的例子可以同时显示两条曲线,分别用点和线的方式。

gnuplot> plot sin(x) with lines title 'Sine Function', \
      tan(x) with points title 'Tangent'

下面的例子可以用不同的颜色显示线。

gnuplot> plot sin(x) with lines linetype 1下面的例子说明如何指定线条的宽度。gnuplot> plot sin(x) with lines linewidth 6类似可以用 pointtype 和 pointsize 指定点的颜色和大小。

可以用 test 命令查看所有支持的 linetype, linewidth, pointtype, pointsize。

也可以用下面的办法指定 line 和 point 的样子。

gnuplot> plot "a.txt" using 1:2 with linespoints linestyle 1
gnuplot> set style line 1 linetype 2 linewidth 1 pointsize 2 pointtype 6
gnuplot> replot
gnuplot> set style line 1 linetype 2 linewidth 1 pointsize 2 pointtype 4
gnuplot> replot
gnuplot> set style line 1 linetype 2 linewidth 1 pointsize 2 pointtype 11
gnuplot> replot下面的例子说明如何指明 X Y 坐标的名称。gnuplot> set xlabel "time(t)"
gnuplot> set ylabel "A"
gnuplot> plot sin(x)

可以用下面的命令处理边框 。

gnuplot> unset border # 没有边框
gnuplot> set border 1 linetype 2 # 下面的边框用 linetype 2
gnuplot> replot
gnuplot> set border 2 linetype 3 # 左面的边框用 linetype 3
gnuplot> replot
gnuplot> set border 3 linetype 3 # 下面和左面的边框用 line type 3border 后面的数字是一个12个bit 的整数,每一位bit 表示一个边框。于是 1 ,2, 4, 8 分别对应下,左,上,右边框。

可以用 set grid 来控制背景栅格。查看帮助 help set grid

gnuplot> set grid
gnuplot> unset grid

可以用 set key 来控制曲线名称的摆放位置。查看帮助 help set key

gnuplot> plot sin(x) title "Sine X"
gnuplot> set key top left
gnuplot> replot

可以用下面的办法增加一个标记。查看帮助 help set arrow , help set label

gnuplot> set label 1 "Peak" at -5,0.8 right
gnuplot> set arrow 1 from -5,0.8 to -0.9,0.9 head
gnuplot> replot

可以用下面的办法给图增加一个标题。查看帮助 help set title

gnuplot> set title "My Figure 1"
gnuplot> replot

可以用下面的办法控制坐标的刻度的表示。查看帮助 help set xtics

gnuplot> set xtics ("left" -5, "middle" 0, "right" 5);
gnuplot> set ytics ("max" 1, "zero" 0, "min" -0.2);
gnuplot> plot [-10:10] [-1:2] sin(x)/x

用下面的办法可以查看一个数据文件中第二列和第三列的和的处理后数据。

gnuplot> plot "a.txt" using 1:($2+$3), "a.txt" using 1:2,"a.txt" using 1:3

可以用下面的办法,把绘图输出到 jpeg 格式的。

$echo "set terminal jpeg small ; plot sin(x)" | gnuplot   > a.jpg

可以 plot 用一些外部命令处理后的数据

gnuplot> plot "< awk '{print $1,$2+$3,$2}' < a.txt" using 1:2
阅读(3399) | 评论(0) | 转发(2) |
给主人留下些什么吧!~~