Gnuplot简单使用
Gnuplot_simple_use

Gnuplot简单使用2008年12月一、最简单的例子gnuplot>plot sin(x)其中gnuplot> 为命令提示符,不是命令的一部分,结果如下:二、加入设置1、设置x、y坐标的范围改变坐标范围set xrange [xmin:xmax] set yrange [ymin:ymax]让gnuplot决定坐标轴范围gnuplot>set autoscale也可以只在本次绘图中设置,使用plot [xmin:xmax] [ymin:ymax] f(x),例如:gnuplot>plot [0:5] [-2:2] sin(x) ,结果如下可只设置x或y的范围,如只设置x范围gnuplot>plot [0:5] sin(x)结果:只设置y的范围gnuplot>plot [] [0:1] sin(x)结果:只设置一边,如设置y为小于0 gnuplot>plot [] [:0] sin(x)结果:2、设置坐标轴名称gnuplot>set xlabel ‘xlabel’ ; set ylabel ‘ylabel’ ; plot sin(x)可以在一行写多个命令,命令间用分号隔开;结果如下:取消坐标轴名称设置gnuplot>unset xlabelgnuplot>unset ylabel3、设置对数坐标设置为对数坐标 set logscale设置x、y轴为对数坐标gnuplot>set logscale xgnuplot>set logscale y取消对数坐标 unset logscale4、设置绘图标题gnuplot>set title ‘title’gnuplot>plot sin(x)取消绘图标题设置unset title5、同时绘制多个函数gnuplot>plot f1(x),f2(x),......fn(x),例如:gnuplot>plot sin(x),x ,结果:6、为曲线设置标题gnuplot>plot f(x) title 'title'例如:gnuplot>plot sin(x) title ‘y=sin(x)’,x title ‘y=x’结果:7、设置曲线标题的放置位置gnuplot>set key x,y其中x,y为横、纵坐标,例如:gnuplot>set key 8,-0.8gnuplot> plot [-10:10] [-1:1] sin(x) title 'sin'将文本‘sin’放置在(8,-0.8)坐标处,结果:将曲线标题放置到默认位置,使用命令:gnuplot>set key default设置不显示曲线标题,使用名令unset key可设置绘图标题框gnuplot>set key box效果如下取消设置绘图标题框,使用命令set key nobox 8、添加网格gnuplot>set grid;plot cos(x)取消网格,使用命令 unset grid三、设置输出1、输出成图片gnuplot>set terminal <类型>其中<类型>为图片的类型,如png、jpeg、gif gnuplot>set output ‘<文件名>’ 设置输出文件名例如:gnuplot>set terminal gifgnuplot>set output ‘sinx.gif’gnuplot>plot sin(x)即会生成名为sinx.gif的图片设置图片的大小set size m,nm,n为放大(缩小)倍数(相对于当前大小),如:set size 1.2, 0.5 将长设置为当前的1.2倍,宽设为当前的 0.5倍2、设置回窗口输出(即默认状态)命令gnuplot>set terminal windows可简写为 se t w3、其他也可设置输出为其他类型文件,如(ps、tex等);也可直接输出到打印机四、三维绘图命令splot用于三维绘图,如:gnuplot>splot x*y五、运算符1、一元的运算符- -a取反! !a逻辑反(a为0,则结果为1,若a为非0,结果为0)! a!阶乘$ $3调用在‘using’中的列2、二元的运算符** a**b乘方,a的b次方* a*b乘,a乘b/ a/b除,a除b% a%b取模,结果为a除b的余数+ a+b加- a-b减== a==b判断等于,若a与b相等,则返回1,否则返回0!= a!=b判断不等,若a与b相等,则返回0,否则返回1< a<b判断小于<= a<=b小于或等于> a>b判断大于>= a>=b大于或等于& a&b按位与^ a^b按位异或| a|b按位或&& a&&b逻辑与|| a||b逻辑或3、三元的运算符?: a?b:c若a为真(1),则结果为b,否则结果为c举例:f(x)=x>=0?-x:x定义一个分段函数发f(x),当x>=0时,f(x)=-x;当x<0时,f(x)=x;以此绘制一张图像gnuplot> f(x)=x>=0?-x:x;plot f(x)结果:六、变量和函数1、变量在gnuplot中,变量一旦被赋值,它即存在了,如:gnuplot>a=1gnuplot>b=’hello’命令show variables将显示已存在的变量,此命令可简写为 sh v 注意:变量名区分大小写2、函数1、内置函数Gnuplot内置有一些有用的函数数学库函数函数 参数类型 返回abs(x) any x的绝对值|x|;abs(x) complex x的长度, sqrt( real(x)^2 + imag(x)^2 ) acos(x) any cos(x) 的反函数acosh(x) anycosh(x)的反函数arg(x) complex the phase of x in radiansasin(x) any sin(x)的反函数asinh(x) any sinh(x)的反函数atan(x) any tan(x)的反函数atan2(y,x) int or realtan−1 (y/x) (inverse tangent)atanh(x) anytanh(x)的反函数besj0(x) radians J0 Bessel function of xbesj1(x) radians J1 Bessel function of xbesy0(x) radians Y0 Bessel function of xbesy1(x) radians Y1 Bessel function of xceil(x) any 不小于x的最小整数cos(x) radians 余弦cosh(x) radians 双曲余弦erf(x) any Erf(real(x)), error function of real(x)erfc(x) any Erfc(real(x)), 1.0 - error function of real(x)exp(x) any e的x次方floor(x) any 不大于x的最大整数gamma(x) any Gamma(real(x)), gamma function of real(x)ibeta(p,q,x) any Ibeta(real(p,q,x)), ibeta function of real(p,q,x)inverf(x) any inverse error function of real(x)igamma(a,x) any Igamma(real(a,x)), igamma function of real(a,x)imag(x) complex x的虚部,返回一个实数invnorm(x) any inverse normal distribution function of real(x)int(x) real 实数的整数部分,小数后面的部分被去除(非四舍五入)lambertw(x) real Lambert W functionlgamma(x) any Lgamma(real(x)), lgamma function of real(x)log(x) any ln(x),x的自然对数 ( 基为e)log10(x) any log(x),x的以十为基的对数norm(x) any normal distribution (Gaussian) function of real(x)rand(x) any Rand(real(x)), pseudo random number generatorreal(x) any x的实部sgn(x) any 符号函数,x>0返回1,x<0返回-1,x=0返回0若x为复数,则x的虚部(imag(x))将被忽略sin(x) radians x的正弦sinh(x) radians x的双曲正弦sqrt(x) any x的开方tan(x) radians x的正切tanh(x) radians x的双曲正切字符串函数gprintf(”format”,x) any string result from applying gnuplot’s format parsersprintf(”format”,x,...) multiple string result from C-language sprintfstrlen(”string”) string int length of stringstrstrt(”string”,”key”) strings int index of first character of substring ”key”substr(”string”,beg,end) multiple string ”string”[beg:end]system(”command”) string string containing output stream of shell command word(”string”,n) string, int returns the nth word in ”string”words(”string”) string returns the number of words in ”string”其他函数column(x) int column x during datafile manipulation.defined(X) variable name [DEPRECATED] returns 1 if X is defined, 0 otherwise. exists(”X”) ”variable name” returns 1 if a variable named X is defined, 0 otherwise. stringcolumn(x) int content of column x as a string.timecolumn(x) int timecolumn x during datafile manipulation.tm_hour(x) int the hourtm_mday(x) int the day of the monthtm_min(x) int the minutetm_mon(x) int the monthtm_sec(x) int the secondtm_wday(x) int the day of the weektm_yday(x) int the day of the yeartm_year(x) int the yearvalid(x) int test validity of column(x) during datafile manip.2、自定义函数在gnuplot中可直接用f(x)=<expression> 来定义函数,<expression>为表达式,如:gnuplot>f(x)=x*x;plot f(x)也可以定义二维函数,如:gnuplot>p(x,y)=sin(x)*cos(y);splot p(x,y)命令show functions可显示已定义的函数,如:gnuplot> show functionsUser-Defined Functions:f(x)=x*xp(x,y)=sin(x)*cos(y)此命令也可简写为show fun 或sh fun或 sh fu 或其他七、文件绘图假设有文件 file.dat,内容如下:10 0.781 0.857 0.96320 0.891 1.053 1.02330 0.950 1.037 1.02540 0.984 0.999 1.01450 1.013 0.998 1.01860 1.000 1.000 1.000使用命令gnuplot>plot 'file.dat'将自动使用第一、二列数据作为点的x、y坐标绘图,结果如下:使用如下命令此时将各点连接起来gnuplot>plot 'file.dat' with lines,结果:使用如下命令将各点用符号标志gnuplot>plot 'file.dat' with linespoints使用如下命令将使用1、3列来绘图gnuplot>plot 'file.dat' using 1:3 with linespoints,结果:使用如下命令将使用第一列与第三列的二分之一绘图gnuplot>plot 'file.dat' using 1:($3/2) with linespoints也可以对某一列使用函数,如:使用命令gnuplot>plot 'file.dat' using 1:(sin($2)) with linespoints 将使用第一列与第二列的正弦绘图,结果:八、常用命令对命令参数的说明1、包括在花括号{} 中的参数是可选的;2、以竖线|分开的命令为多选;1、目录相关命令1、pwdpresent working directory当前工作目录用途:确定你当前所在的目录,这有什么用?如果你工作的目录为数据文件所在目录,那么你在命令行上就不用输入数据文件的完整路径了。
gnuplot set ytics format 科学计数法

gnuplot set ytics format 科学计数法1. 引言在数据可视化和科学计算中,gnuplot是一种广泛使用的绘图工具。
它可以生成高质量的图形,并且具有丰富的配置选项。
其中一个常用的配置选项是set ytics format,用于设置y轴刻度的显示格式。
本文将详细介绍如何使用set yticsformat命令将y轴刻度显示为科学计数法。
2. 基本语法set ytics format命令的基本语法如下:set ytics format "%<format>"其中,<format>是一个格式字符串,用于指定刻度值的显示格式。
在科学计数法中,我们通常使用%e表示指数形式的浮点数。
3. 示例下面是一个简单的示例,演示了如何使用set ytics format将y轴刻度显示为科学计数法:set ytics format "%e"plot "data.txt" using 1:2 with lines在这个示例中,我们假设数据存储在一个名为data.txt的文件中,第一列是x值,第二列是y值。
plot命令用于绘制数据曲线。
4. 设置刻度的精度除了科学计数法之外,set ytics format还可以用于设置刻度的精度。
例如,我们可以使用%.2e将刻度显示为两位小数的科学计数法:set ytics format "%.2e"这将使刻度显示为形如1.23e+02的格式。
5. 自定义刻度标签除了使用默认的科学计数法格式,我们还可以自定义刻度标签。
例如,我们可以使用set ytics format "$%g$"将刻度显示为LaTeX格式:set ytics format "$%g$"这将使刻度显示为形如$1.23$的格式。
6. 设置刻度的位置除了设置刻度的显示格式之外,我们还可以使用set ytics命令设置刻度的位置。
c语言gnuplot例子(一)

c语言gnuplot例子(一)C语言gnuplot例子1. 概述在C语言中,我们可以使用gnuplot库来生成各种图表,包括直方图、散点图、线图等。
这些图表可以帮助我们更直观地理解数据的分布、关系等。
下面是一些常见的例子。
2. 直方图代码#include <>#include <>#include <>#include <>int main(void) {gnuplot_ctrl *h1;FILE *data = fopen("", "w");int i;h1 = gnuplot_init();for (i = 0; i < 100; i++) {fprintf(data, "%d\n", rand() % 100);}fclose(data);gnuplot_cmd(h1, "set terminal png");gnuplot_cmd(h1, "set output ''");gnuplot_cmd(h1, "set title 'Histogram'");gnuplot_cmd(h1, "set xlabel 'Value'");gnuplot_cmd(h1, "set ylabel 'Frequency'");gnuplot_cmd(h1, "binwidth=1");gnuplot_cmd(h1, "bin(x,width)=width*floor(x/width) + width/");gnuplot_cmd(h1, "plot '' using (bin($1,binwidth)):() smooth freq with boxes");gnuplot_close(h1);return 0;}说明这个例子演示了如何使用gnuplot库生成直方图。
gnuplot画圆形的方程

gnuplot画圆形的方程圆形是一个非常基本的几何图形,它在数学和物理学中都有广泛的应用。
在本文中,我们将使用gnuplot这个强大的绘图工具来画圆形的方程。
我们需要了解圆形的方程是什么样的。
圆形的方程可以表示为:(x - a)^2 + (y - b)^2 = r^2其中,(a, b)是圆心的坐标,r是圆的半径。
这个方程告诉我们,圆上的每一个点(x, y)都满足这个方程。
现在我们可以使用gnuplot来绘制一个圆形。
首先,我们需要打开gnuplot的绘图窗口。
在终端中输入gnuplot命令后,窗口将会打开。
接下来,我们需要设置绘图的范围。
可以使用命令“set xrange”和“set yrange”来设置x和y轴的范围。
例如,我们可以设置x 轴的范围为-10到10,y轴的范围也为-10到10:set xrange [-10:10]set yrange [-10:10]然后,我们可以使用命令“set size square”来设置绘图窗口的宽高比为1:1,这样绘制出的圆形才不会被拉伸或压缩。
命令如下:set size square接下来,我们需要使用命令“plot”来绘制圆形的方程。
在plot命令后面加上圆形的方程即可。
例如,如果我们要绘制圆心坐标为(0, 0),半径为5的圆形,命令如下:plot (x-0)**2 + (y-0)**2 = 5**2我们可以使用命令“pause -1”来保持绘图窗口的显示,这样我们就可以看到绘制出的圆形了。
命令如下:pause -1通过以上步骤,我们就成功地使用gnuplot绘制了一个圆形。
当然,我们还可以通过修改圆心坐标和半径来绘制不同的圆形。
除了绘制圆形,gnuplot还可以绘制其他的几何图形,如直线、矩形等。
我们可以通过修改绘图命令来绘制不同的图形。
例如,如果我们要绘制一个直线的方程为y = 2x + 3,命令如下:plot 2*x + 3绘制矩形的方法也类似,只需要设置矩形的四个顶点的坐标即可。
gnuplot 卷积运算

gnuplot卷积运算Gnuplot本身不直接提供卷积运算的功能,但你可以通过使用Gnuplot进行数据处理和可视化来实现卷积运算。
具体步骤如下:1.准备数据首先,你需要准备要进行卷积运算的数据。
这些数据可以是从文件中读取的实际数据,或者是你自己生成的模拟数据。
2.编写卷积运算的脚本使用Gnuplot的计算功能,编写一个脚本来进行卷积运算。
这可能涉及到对数据进行窗口滑动、加权和求和等操作。
3.绘制卷积结果将卷积运算的结果绘制成图表。
使用Gnuplot的绘图功能,将卷积后的数据可视化展示。
以下是一个简单的伪代码示例,演示如何在Gnuplot中进行卷积运算:#读取数据data="your_data_file.dat"set table'convolution_result.dat'#执行卷积运算(示例中使用的是简单的平滑卷积)kernel=1/3*[1,1,1]#定义卷积核,例如平均滤波器convolution(x)=(kernel[1]*column(x-1)+kernel[2]*column(x)+kernel[3]*column( x+1))plot data using 1:(convolution(2))with lines这个示例展示了如何使用Gnuplot读取数据文件,定义一个简单的卷积核(平均滤波器),并对数据进行卷积运算。
你可以根据需要自定义卷积核和卷积的方式,以适应你的具体场景。
请记住,Gnuplot并不是一个专门用于数据处理的工具,它更适合用于数据可视化。
如果需要更复杂的卷积运算或其他数据处理任务,可能需要结合其他工具或编程语言来完成。
Gnuplot简易中文入门指南

Gnuplot 使用技巧郑小宏2005-10-21对于在Linux下工作的人,如果你经常要画一些二维图和简单的三维图的话,那么,gnuplot无疑是一个非常好的选择,不仅图形漂亮,而且操作简单。
当然如果需要质量更高的三维图,请用其他的一些专业绘图软件。
建议大家学会使用gnuplot。
这个小软件通常都是Redhat Linux自带的,但自带的版本是3.7的,建议将其升级到4.0,新版本具有很多新功能。
最新版本可以到下载。
一些最基本的操作请大家看说明书。
这里总结一下我在使用过程中遇到的一些问题以及解决的办法,目的是让那些以前不会的或不熟练的能快速入门,会画自己想要的图,因为原来的说明书很长,较难有针对性地很快找到自己想要的信息。
这里简单的总结不可能面面俱到,所以大家不要抱怨我写的不全,更全面的了解还是请看说明书,网上的资料也多的是。
其实这也是我们从网上一点一点搜集和摸索出来的。
我相信看完后,应该平时最常见的问题基本上都能在这里找到答案。
如果大家在使用过程中摸索到了我没有写到的技巧和体会,或有其它建议,请大家提告诉我,以不断完善这篇总结,谢谢!一、基础篇:在linux命令提示符下运行gnuplot命令启动,输入quit或q或exit退出。
1、plot命令gnuplot> plot sin(x) with line linetype 3 linewidth 2 或gnuplot> plot sin(x) w l lt 3 lw 2 %用线画,线的类型(包括颜色与虚线的类型)是3,线的宽度是2,对函数sin(x)作图gnuplot> plot sin(x) with point pointtype 3 pointsize 2 或gnuplot> plot sin(x) w p pt 3 ps 2 %用点画,点的类型(包括颜色与点的类型)是3,点的大小是2gnuplot> plot sin(x) title 'f(x)' w lp lt 3 lw 2 pt 3 ps 2 %同时用点和线画,这里title ‘f(x)’表示图例上标'f(x)',如果不用则用默认选项gnuplot> plot sin(x) %此时所有选项均用默认值。
利用Gnuplot简单实现性能指标分析图

利用 Gnuplot 简单实现性能指
标分析图
生成性能指标报告
生成性能指标步骤:
1.通过linux命令实时收集性能指标 2.通过linux脚本分析性能指标并生成更为简洁的指标报告 3.利用Gnuplot分析指标报告并生成指标趋势折线图
1.通过linux命令实时收集性能指标: 性能测试过程中比较关心的指标有:负载、磁盘繁忙度、内存使用率、CPU 使用率 负载:通过uptime命令,获取平均负载 磁盘繁忙度:通过iostat –x内存使用率 CPU使用率:通过/proc/stat来计算CPU使用率 最终生成性能日志文件
生成性能日志文件的脚本:
#!/bin/sh INTERVAL=10 RUNFILE=/shell/running file=/shell/server_status.log cat /dev/null > ${file} while test -e $RUNFILE;do sleep=$(date +%s.%N | awk "{print $INTERVAL - (\$1 % $INTERVAL)}") sleep $sleep ts="$(date +"TS %s.%N %F %T")" loadavg="$(uptime)" echo "$ts $loadavg" >> ${file} mem="$(free -m|grep Mem)" echo "$mem" >> ${file}
Gnuplot简介

Gnuplot简介本文来自:/Kawano/gnuplot/intro/index-e.htmlGNUPLOT 是用于显示数学函数和数据图形的自由软件,有许多网站有相关文档,因此这里仅对如何根据试验数据或数值计算结果作图进行描述。
1.基本用法Gnuplot已经移植到各种不同的操作系统下,用法也略有不同,这里对UNIX 的X11环境下进行介绍。
因为大部分用法是通用的,因此本教程也可作为其它环境下使用的参考。
首先,执行Gnuplot,显示banner和credit后出现Gnuplot命令行提示符"gnuplot>"。
Gnuplot是命令行驱动的作图工具,在命令提示符下输入命令作图。
% gnuplotG N U P L O TV ersion 4.0 patchlevel 0last modified Thu Apr 15 14:44:22 CEST 2004System: Linux 2.4.23Copyright (C) 1986 - 1993, 1998, 2004Thomas Williams, Colin Kelley and many othersThis is gnuplot version 4.0. Please refer to the documentationfor command syntax changes. The old syntax will be acceptedthroughout the 4.0 series, but all save files use the new syntax.Type `help` to access the on-line reference manual.The gnuplot FAQ is available from/faq/Send comments and requests for help to<gnuplot-info@>Send bugs, suggestions and mods to<gnuplot-bugs@>Terminal type set to 'x11'gnuplot>在Gnuplot中有很多命令,很难全部解释,这里仅介绍用Gunplot作图的最简单用法,可以用help命令得到相关命令的帮助。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Gnuplot简单使用2008年12月一、最简单的例子gnuplot>plot sin(x)其中gnuplot> 为命令提示符,不是命令的一部分,结果如下:二、加入设置1、设置x、y坐标的范围改变坐标范围set xrange [xmin:xmax] set yrange [ymin:ymax]让gnuplot决定坐标轴范围gnuplot>set autoscale也可以只在本次绘图中设置,使用plot [xmin:xmax] [ymin:ymax] f(x),例如:gnuplot>plot [0:5] [-2:2] sin(x) ,结果如下可只设置x或y的范围,如只设置x范围gnuplot>plot [0:5] sin(x)结果:只设置y的范围gnuplot>plot [] [0:1] sin(x)结果:只设置一边,如设置y为小于0 gnuplot>plot [] [:0] sin(x)结果:2、设置坐标轴名称gnuplot>set xlabel ‘xlabel’ ; set ylabel ‘ylabel’ ; plot sin(x)可以在一行写多个命令,命令间用分号隔开;结果如下:取消坐标轴名称设置gnuplot>unset xlabelgnuplot>unset ylabel3、设置对数坐标设置为对数坐标 set logscale设置x、y轴为对数坐标gnuplot>set logscale xgnuplot>set logscale y取消对数坐标 unset logscale4、设置绘图标题gnuplot>set title ‘title’gnuplot>plot sin(x)取消绘图标题设置unset title5、同时绘制多个函数gnuplot>plot f1(x),f2(x),......fn(x),例如:gnuplot>plot sin(x),x ,结果:6、为曲线设置标题gnuplot>plot f(x) title 'title'例如:gnuplot>plot sin(x) title ‘y=sin(x)’,x title ‘y=x’结果:7、设置曲线标题的放置位置gnuplot>set key x,y其中x,y为横、纵坐标,例如:gnuplot>set key 8,-0.8gnuplot> plot [-10:10] [-1:1] sin(x) title 'sin'将文本‘sin’放置在(8,-0.8)坐标处,结果:将曲线标题放置到默认位置,使用命令:gnuplot>set key default设置不显示曲线标题,使用名令unset key可设置绘图标题框gnuplot>set key box效果如下取消设置绘图标题框,使用命令set key nobox 8、添加网格gnuplot>set grid;plot cos(x)取消网格,使用命令 unset grid三、设置输出1、输出成图片gnuplot>set terminal <类型>其中<类型>为图片的类型,如png、jpeg、gif gnuplot>set output ‘<文件名>’ 设置输出文件名例如:gnuplot>set terminal gifgnuplot>set output ‘sinx.gif’gnuplot>plot sin(x)即会生成名为sinx.gif的图片设置图片的大小set size m,nm,n为放大(缩小)倍数(相对于当前大小),如:set size 1.2, 0.5 将长设置为当前的1.2倍,宽设为当前的 0.5倍2、设置回窗口输出(即默认状态)命令gnuplot>set terminal windows可简写为 se t w3、其他也可设置输出为其他类型文件,如(ps、tex等);也可直接输出到打印机四、三维绘图命令splot用于三维绘图,如:gnuplot>splot x*y五、变量和函数1、变量在gnuplot中,变量一旦被赋值,它即存在了,如:gnuplot>a=1gnuplot>b=’hello’命令show variables将显示已存在的变量,此命令可简写为 sh v注意:变量名区分大小写2、函数(1)内置函数Gnuplot内置有一些有用的函数函数 补充 返回abs(x) any x的绝对值|x|;abs(x) complex length of x, sqrt( real(x)^2 + imag(x)^2 )acos(x) any 1/cos(x) (inverse cosine) in radiansarg(x) complex the phase of x in radiansasin(x) any 1/sin(x) (inverse sin) in radiansatan(x) any 1/tan(x) (inverse tangent) in radiansbesj0(x) radians J0 Bessel function of xbesj1(x) radians J1 Bessel function of xbesy0(x) radians Y0 Bessel function of xbesy1(x) radians Y1 Bessel function of xceil(x) any smallest integer not less than x (real part)cos(x) radians cos x, cosine of xcosh(x) radians cosh x, hyperbolic cosine of xerf(x) any Erf(real(x)), error function of real(x)erfc(x) any Erfc(real(x)), 1.0 - error function of real(x)exp(x) any exponential function of xfloor(x) any largest integer not greater than x (real part) gamma(x) any Gamma(real(x)), gamma function of real(x) ibeta(p,q,x) any Ibeta(real(p,q,x)), ibeta function of real(p,q,x) inverf(x) any inverse error function of real(x)igamma(a,x) any Igamma(real(a,x)), igamma function of real(a,x) imag(x) complex imaginary part of x as a real numberinvnorm(x) any inverse normal distribution function of real(x) int(x) real integer part of x, truncated toward zerolgamma(x) any Lgamma(real(x)), lgamma function of real(x) log(x) any ln(x),x的自然对数 ( 基为e)log10(x) any log(x),x的以十为基的对数 ( 基为10)norm(x) any normal distribution (Gaussian) function of real(x)rand(x) any Rand(real(x)), pseudo random number generatorreal(x) any real part of xsgn(x) any 1 if x>0, -1 if x<0, 0 if x=0. imag(x) ignoredsin(x) radians x的正弦sinh(x) radians x的双曲正弦sqrt(x) any x的开方tan(x) radians x的正切tanh(x) radians x的双曲正切(2)自定义函数在gnuplot中可直接用f(x)=<expression> 来定义函数,<expression>为表达式,如:gnuplot>f(x)=x*x;plot f(x)也可以定义二维函数,如:gnuplot>p(x,y)=sin(x)*cos(y);splot p(x,y)命令show functions可显示已定义的函数,如:gnuplot> show functionsUser-Defined Functions:f(x)=x*xp(x,y)=sin(x)*cos(y)此命令也可简写为show fun 或sh fun或 sh fu 或其他六、文件绘图假设有文件 file.dat,内容如下:10 0.781 0.857 0.96320 0.891 1.053 1.02330 0.950 1.037 1.02540 0.984 0.999 1.01450 1.013 0.998 1.01860 1.000 1.000 1.000使用命令gnuplot>plot 'file.dat'将自动使用第一、二列数据作为点的x、y坐标绘图,结果如下:使用如下命令此时将各点连接起来gnuplot>plot 'file.dat' with lines,结果:使用如下命令将各点用符号标志gnuplot>plot 'file.dat' with linespoints使用如下命令将使用1、3列来绘图gnuplot>plot 'file.dat' using 1:3 with linespoints,结果:使用如下命令将使用第一列与第三列的二分之一绘图gnuplot>plot 'file.dat' using 1:($3/2) with linespoints也可以对某一列使用函数,如:使用命令gnuplot>plot 'file.dat' using 1:(sin($2)) with linespoints 将使用第一列与第二列的正弦绘图,结果:七、常用命令pwd (present working directory)当前工作目录cd ‘< directory >’(come directory)到某个目录,<directory>是想要到的目录名,如gnuplot>cd ‘c:\gnuplot’clear 清空输出的图像exit和quit 退出gnuplot,也可简写为qpause <seconds>暂停一段时间,<seconds>为时间,单位为秒print <var> 其中<var>为变量名,例如gnuplot>a=1gnuplot> print a1输出a的值,也可输出字符串gnuplot> print ‘hello’hello输出字符串hello也可以用双引号代替单引号,有何区别?在上面的例子中输出是完全一样的,但下面的例子将显示其区别gnuplot> print ‘hello\neveryone’hello\neveryonegnuplot> print “hello\neveryone”helloeveryone即单引号屏蔽转义符号 ’\’,而双引号则不会,它将 \n 看成换行,另外还有 \t 表示制表符。