我的新博客

gnuplot 学习笔记

1 如何运行

gnuplot是一个命令行输入的工具,把命令行写入一个文本file1 file2。使用下列方式运行。

gnuplot {option} file1 file2

2 产生一个图标,不管数据怎么变化保持不变

gnuplot -persist -e "set title 'Sine curve'; plot sin(x)"

3.画面尺寸 set tem <terminal_type> size <xx>,<yy>. 而画图的大小命令为set size <x>,<y> 当x,y小于1时画图小于整个画布,大于1时只显示数据的一部分

4 坐标

set arrow, set key, set label and set object可以在图中任意位置画。位置坐标的语法是:

{<system>} <x>,{<system>} <y> {,{<system>} <z>} 

这里的 system 可以是first(左和下) ,second(上和右), graph(00为左下,11为右上), screen或者character.

5 画正弦 plot sin(5*x).默认100个采样点,采样率较低,更改采样率为500个.set samples 500

然后重画。replot

6.去掉图例 unset key  然后replot生效 加上title : set title "sin(5*x)函数图像"

加上坐标 set xlabel "x"    set ylabel "y" 还是replot生效

设置x坐标范围 set xrange[-2*pi:2*pi]还是replot

设置坐标轴刻度 set xtics pi. set mxtics 2

7 读取文件中的数据并画图

  plot  文件名。 文件中的数据x.y按列存放。

默认为点型 ,改成线形加with lines

8 数据文件中含组个数据 命令using选择使用哪个可简写为u,可对数据进行处理,如下例

u 1:($2*3+13),

9.动画

 1 set term gif animate delay 1 # time between frame
 2 set output "sinous.gif"
 3 #f(x,t) = sin(x+t)
 4 #set term wxt enhanced
 5 set samples 2000 #
 6 set xrange[-4*pi:4*pi]
 7 unset key
 8 set tics textcolor rgb "orange"
 9 set border lc rgb "orange"
10 set grid lc rgb "orange"
11 i = 0;
12 load "looper.gnu"
13 set output
14 #for [t = 0:1:100] plot f(x,t); 

looper.gnu的内容

1 set object 1 rectangle from screen 0,0 to screen 1,1 fc rgb "gray10"  behind
2 plot sin(x+i*pi/20) lw 3 lc rgb "green" notitle
3 i = i+ 1
4 if (i<40) reread

 

posted @ 2016-08-31 01:54  Leon#0534  阅读(486)  评论(0编辑  收藏  举报

我的新博客

专注天线学习,欢迎交流 yangli0534@gmail.com - 创建于 2010年

我永远是茫茫EE领域的一名小学生。