您的位置:首页 > 其它

Gnuplot学习笔记

2015-12-21 22:55 253 查看
#1设置x、y坐标范围

set xrange[-5:5] yrange[-2:2]

#也可以这样:

plot [-5:5] [-2:2] sin(x)

#2设置坐标轴名称、标题

set xlabel 'xlabel' ;

set ylabel 'ylabel' ;

set title 'title' ;

#3为曲线设置标题

plot sin(x) title 'y=sin(x)',x title 'y=x'

#设置标题的位置:

set key x y

set key default

#不设置标题:

unset key

#4网格

set grid

#5设置输出

set terminal jpeg

set output 'sinx.jpg'

set size m,n //m,n为放大(缩小)倍数

set terminal windows //简写 se t w

#6三维绘图

splot x*y

#7运算符

f(x)=x?>=x?-x:x;plot f(x)

#8自定义函数

f(x)=x*x; plot f(x)

p(x,y)=x*x+y*y; splot p(x,y)

#9文件绘图

#cat file.dat:

10 0.781 0.857 0.963

20 0.891 1.053 1.023

30 0.950 1.037 1.025

40 0.984 0.999 1.014

50 1.013 0.998 1.018

60 1.000 1.000 1.000

#

cd 'file-dir' ; pwd

#将使用第前两列作为x、y坐标数据:

plot 'file.dat'

plot 'file.dat' with lines/linespoint

#使用第一列与第三列数据绘图:

plot 'file.dat' using 1:3 with linespoint

#使用第一列与第三列的二分之一数据绘图:

plot 'file.dat' using 1:($3/2) with linespoint

#使用函数操作数据:

plot 'file.dat' using 1:(sin($2)) with linespoint

#10脚本功能

load file.plt

call file.plt

#call只是比load多个参数读取,$#为参数个数,$n为参数引用。

如:cat test.plt :

set ter jpeg

set out 'out.jpg'

plot x**3 title 'x^3', x*x title 'x^2'

#调用:

call 'test.plt'

#这样也行:

$cat test.plt | gnuplot
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: