logo资料库

gnuplot 中文手册 修订2.pdf

第1页 / 共197页
第2页 / 共197页
第3页 / 共197页
第4页 / 共197页
第5页 / 共197页
第6页 / 共197页
第7页 / 共197页
第8页 / 共197页
资料共197页,剩余部分请下载后查看
第一部分
GnuPlot 4.6
版权
前言
新特性
新语法
本地化的linetypes 用户设置
新的 plot styles
翻转坐标轴
新的平滑算法
新的时间和日期处理
数据统计汇总
反向兼容
批量处理和交互操作
画布尺寸
注释
坐标
字符串数据
增强文本模式
环境变量
表达式
函数
椭圆函数
产生随机数
运算符
一元运算符
二元运算符
三元运算
Gnuplot 内建变量
用户定义变量和函数
字体
Cairo (pdfcairo, pngcairo, wxt 终端)
Gd (png, gif, jpeg terminals)
Postscript encapsulated postscript *.eps
特殊词汇
线条样式, 色彩, 样式
颜色指定
Rgb色彩变量
线条色彩变量
绑定
绑定空格
鼠标输入
鼠标变量
绘图命令
初始化脚本
字符串常量和字符串变量
命令替换和命令行宏
变量替换和宏
字符串,宏,命令替换
语法
引号
日期和时间
第二部分
绘画样式
Boxerrorbars
Boxes
Boxplot
Boxxyerrorbars
Candlesticks
Circles
Ellipses
Dots
Filledcurves
Financebars
Fsteps
fillsteps
Histeps
Histograms
Newhistogram
在多列中自动递增
Image
透明度
image样式容错
Impulses
Labels
Lines
Linespoints
Points
Polar
steps
vectors
xerrorbars
xyerrorbars
xerrorlines
xerrorline只用于2d绘制。它是xerrorbars样式和lines样式结合的产物。
4 columns: x y xdelta ydelta
6 columns: x y xlow ylow yhigh
xyerrorlines
yerrorlines
3D面绘制
3d to 2d映射(set view map)
第三部分
命令
cd
call
clear
do
evaluate
exit
fit
待校准参数
简要指南
误差估算
控制fit命令
控制变量:
环境变量
多分支
help
history
if
旧if
迭代
load
pause
Plot
关键字:axes
关键字:binary
关键字:array
关键字:record
关键字:skip
关键字:format
关键字:endian
关键字:filetype
其他关键字
数据
关键字:every
语法:
数据文件实例
index
smooth
特殊文件名
using
Xticlabels
Volatile
函数
parametric
范围
迭代
title
with
print
Pwd
quit exit
Raise
Refresh
Replot
Reread
Reset
Save
Set/show
Angles
Arrow
autoscale
parametric 模式
polar 模式
Bars
Bind
Bmargin
Border
Boxwidth
clabel
clip
cntrparam
color box
Contour
Datafile
set datafile fortran
set datafile nofpe_trap
set datafile missing
set datafile separator
set datafile comentschars
set datafile binary
decimalsign
Dgrid3d
dummy
Encoding
Fit
Fontpath
Format
gprintf
格式化占位符
时间日期格式化占位符
functions
grid
Hidden3d
Historysize
Isosamples
Key
图例位置:
图例样本
Label
linetype
Lmargin
loadpath
Locale
logscale
macros
mapping
Margin
Mouse
doubleclick
Mouseformat
滚动
X11
缩放
Multiplot
Mx2tics
Mxtics
my2tics
mytics
mztics
object
Rectangel
ellipse
Circle
Polygon
offsets
Origin
output
Parametric
Plot
pm3d
算法
position(位置)
scanorder(采样顺序)
clipping
色彩赋值
Hidden3d
采样补间
废弃的选项
Palette
Rgbformulae
Defined
function
cubehelix
file
伽玛校正
Postscript
Pointintervalbox
Pointsize
Polar
print
Psdir
raxis
Rmargin
rrange
Rtics
Samples
size
Style
set style arrow
boxplot
set style fill
set style fill transparent
Set style function
set style increment
set style line
Set style circle
set style rectangle
set style ellipse
Surface
Table
Terminal
Termoption
tics
Ticslevel
ticscale
timestamp
timefmt
Title
Tmargin
trange
urange
variables
Version
View
equal_axes
Vrange
x2data
x2dtics
x2label
x2mtics
x2range
x2tics
x2zeroaxis
xdata
Xdtics
xlabel
Xmtics
xrange
xtics
xtics 时间数据
rangelimited
Xyplane
xzeroaxis
y2data
y2dtics
y2label
y2mtics
y2range
y2tics
y2zeroaxis
ydata
ydtics
ylabel
ymtics
yrange
ytics
yzeroaxis
zdata
zdtics
zlabel
zmtics
zrange
ztics
zeroaxis
Zero
Zeroxis
shell
splot
数据文件
Matrix
数据文件实例
网格数据
绘制曲面
stats 统计命令
System
test
Undefine
unset
update
while
第四部分
常用的终端列表
Aqua
Canvas
Cairolatex
Cgi
Cgm
Contex
Corel
Debug
Dumb
dxf
Dxy800a
Eepic
Emf
Emxvga
Epscairo
Epslatex
Epson_180dpi
fig
ggi
gif
jpeg
latex
mp
pbm
pdf
pdfcairo
png
pslatex 和pstex
pstricks
Qt
tpic
wxt
X11
第一部分 GnuPlot 4.6 中文手册 当前修订次数:2 版权 Copyright (C) 1986 - 1993, 1998, 2004, 2007 Thomas Williams, Colin Kelley Permission to use, copy, and distribute this software and its documentation for any purpose with or without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Permission to modify the software is granted, but not the right to distribute the complete modified source code. Modifications are to be distributed as patches to the released version. Permission to distribute binaries produced by compiling modified sources is granted, provided you 1. distribute the corresponding source modifications from the released version in the form of a patch file along with the binaries, 2. add special version identification to distinguish your version in addition to the base release version number, 3. provide your name and address as the primary contact for the support of your modified version, and 4. retain our contact information in regard to use of the base software. Permission to distribute the released version of the source code along with corresponding source
modifications in the form of a patch file is granted with same provisions 2 through 4 for binary distributions. 作者 Original Software: Thomas Williams, Colin Kelley. Gnuplot 2.0 additions: Russell Lang, Dave Kotz, John Campbell. Gnuplot 3.0 additions: Gershon Elber and many others. Gnuplot 4.0 additions: See list of contributors at head of this document. 译者:三寸断梁 前言 本文档针对 4.6 版手册翻译了全文大约%85 的内容,终端部分从略。本手册是本人空闲时间学习 gnuplot 而翻译,疏漏难免。不保证含义准确,仅供参考。若发现手册中有错误可以报告: gnuplot_cn_manual@126.com ,邮件主题必须以"gnuplot: " 开始,否则系统不接收,成功后你可以 收到自动回复的邮件。 Gnuplot 是一个小巧的命令行绘图工具,运行于 LINUX ,OS/2,MS Windows,VMS 等等其它平台。 它的源代码开放。它最初被设计为科学家或学生交互式创建函数图像和数据图表。但是现在它也作为一 个绘图引擎用于其它程序,octave 是一个例子。 Gnuplot 支持多种类型的绘图,2D 和 3D。它能利用线段,点,直方图,或者其它元素绘制你需要的 图形。同时你可以在图形中添加一些文本。 Gnuplot 支持多种类型的输出类型:交互式屏幕终端(鼠标、键盘),直接输出多种文件格式 (png,jpg,LaTeX,pdf,postscript)或者现代打印机。Gnuplot 很容易扩展去支持新的输出类型。最新 的支持有基于 wxWidgets 的交互终端,QT。将输出 web 页面可以使用 svg 或者 HTML5 canvas 输出类型。 Gnuplot 是大小写敏感的。所有的命令名和关键字在它无歧义时可以缩写 1。在命令尾部使用分号可 以让多条命令出现在同一行。字符串可以用双引号或单引号括主,有少许不同。 1 plot "data" using 1:2 with lines; 可以缩写为: plot "data" u 1:2 w l;
如果一条命令太长可以在末尾使用反斜线后在下一行继续(反斜线必须是此行的最后一个字符): plot sin(x),f2(x),f3(x),\ f4(x),f5(x); 但是如果发生错误,命令解析器无法准确定位到出错的行。在本文中花括号用于表示可选参数,管 道符号用于分割一些可选选项。<>用于表示可认为更改的部分。 Gnuplot 在命令行上使用 gnuplot {OPTIONS} file1 file2. … ; 启动。对于 X11 系统 可以使用:gnuplot {X11OPTIONS} {OPTIONS} file1 file2 ... 具体查阅 X11 的文档。 命令行中的选项可以出现在行的任何地方,文件名将按顺序依次执行。 - 作为文件名,让 gnuplot 从标准输入读取。 新特性 本节介绍 4.4 版本以来主要的附加功能。详见 NEWS 文件。 新语法 这个版本的 gnuplot 新增了佚代指令,和块结构(if else while do)详见后文。简单的佚代指令可以在 plot set 命令中使用。例如: set multiplot layout 2,2 100 term Fourier series fourier(k, x) = sin(3./2*k)/k * 2./3*cos(k*x) do for [power = 0:3] { TERMS = 10**power set title sprintf("%g term Fourier series",TERMS) plot 0.5 + sum [k=1:TERMS] fourier(k,x) notitle } nset multiplot 本地化的 linetypes 用户设置 你可以设置默认的 linetype,详见set linetype。这通常在启动文件中设置。 新的 plot styles 查看 plot styles :boxplot,circles,ellipses 的文档。
翻转坐标轴 坐标轴现在可以不使用 x y 命名。详情查看 set polar and set rrange 新的平滑算法 新的算法支持 2d 3d 绘制。smooth kdensity 或者 smooth cumulative 同 plot 指令同时使用。 新的时间和日期处理 Gnuplot 现在使用毫秒(千分之一秒)精度。时间数据必须被格式化成规定格式。内建函数 time()返 回当前系统时间。例如输出时间: print strftime("%H:%M:%.3S %d-%b-%Y",time(0.0)) 18:15:04.253 16-Apr-2011 数据统计汇总 新命令 stats 从文件读取数据,使用 plot 相同的语法。并且输出统计汇总,包括最大值,最小值,众数, 平均值,标准差,关联性。等等。 反向兼容 Gnuplot 4.0 摒弃了旧版本中的部分语法。但是仍然对它们提供了支持。需要在编译时提供支 持:./configure --enable-backwards-compatibility 。 Deprecated: set title "Old" 0,-1 set data linespoints plot 1 2 4 # horizontal line at y=1 New: TITLE = "New" set title TITLE offset char 0, char -1 set style data linespoints plot 1 linetype 2 pointtype 4 批量处理和交互操作 Gnuplot 既可以从文件读取命令执行,也可以交互运行。使用-e "command" 将执行一个 gnuplot
命令。 使用-persist 直接从命令行读取程序。退出后窗体后台保留。 gnuplot -persist -e "set title 'Sine curve'; plot sin(x)" 设置变量影响脚本执行。 gnuplot -e "a=2; s='file.png'" input.gpl 画布尺寸 以前版本 gnuplot,对于某些终端类型使用 set size 命令控制画布大小,而其它终端用其它方法。4.2 版本以来 set size 命令被放弃。4.4 版本几乎所有的终端类型使用同样的语法。 set term size , 默认情况下,输出将使用整个画布。 set size , 缩放 plot 相对于画布的大小。值小于 1 表示 plot 不使用整个画布。值大于 1 表示 plot 的某一部分将会被显示在画布上。在某些终端类型下值大于 1 会出错。 这个规则的主要例外是,PostScript 驱动。 set size 0.8, 0.5 set term png size 400, 400 set output "figure.png" plot sin(x),x 这些指令用于绘制一个 400*400 大小的 png 图片,绘制区域横向使用 80% 纵向使用 50%(下图蓝 色边框是译者加入的):
注释 脚本中的注释 #开始一直到行尾。 数据文件中的注释由 set datafile commentschars 设定,默认为#。 坐标 set arrow, set key, set label 和 set object 命令允许使用坐标作为参数,坐标的表示方法为: {} , {} {,{} } 可以为 first, second, graph, screen, 或者 character. First 设置 xyz 值到第一坐标系1,second 设置 xyz 到第二坐标系,graph 设置相对与图像区域的比 例,0,0 代表左底点,1,1 右上点。screen 代表坐标相对与整个画布2, 0,0 代表画布左底点,1,1 画布右 上点。character 关键字,坐标位置决定于字符的宽或高,因此它和当前字体相关。参考:page 7 如果 x 没有指定坐标系,默认使用 first,如果 y 没指定,默认依赖于 x。 某些情况下需要使用相对坐标(例如 set arrow 的第二个参数)。如果给定坐标处于对数坐标系,那么 值被解释为比例因子。例如: set logscale x set arrow from 100,5 rto 10,2 箭头从 100,5 指向 1000,7 如果某个轴的数据是日期,那么必须使用满足 set timefmt 格式的字符串。 字符串数据 数据文件现在可以包括字符串数据。字符串可以包括任意可显示字符。 1.000 2.000 "NUM ONE" 2.00 gnuplot 有两个坐标系统参见 24 1 2 画布和图像区域,前者范围大于图像区域。系统在图像区域之外的画布区域为坐标轴注明刻度标签。
2,000 1.000 "N. TWO" 3.00 此行数据含有 4 列。 2D 或者 3D plot 指令可以将文本字段自动定位。 plot 'datafile' using 1:2:3 with labels 这些命令将从文件中读取数值作为坐标,将字符串写在指定坐标处。 读取字符串并将它写在横轴标点,可用于直方图的命名。 reset set xtics set term png size 400,400 set output 'f.png'; plot [0:3][0:3] "data" using 1:2:xticlabels(3) title "data" 注:图中蓝色区域为译者加入,为了让读者看到图像边界。坐标轴以内的区域为 graph 区域(图像区 域),之外的白色区域为 screen 区域(画布区域)。
增强文本模式 与 tex 兼容的表达方法用于 输入数学公式。花括号用于 字符分组。例如: a^x+2 ax+2 a^{x+2} ax+2 a^10 a10 注意 这个 10 是作为两个元素处理的。 a^{10} a10 set termoption enhanced 开启增强模式 set label 'x 2' noenhanced 关闭增强模式 想指定字体或者字体大小请使用完整的格式: {/[fontname][=fontsize | *fontscale] text}例如: {/Symbol=20 G} 表示 20pt 的字符 G,{/*0.75 K} 字符 K,尺寸为当前尺寸的 3/4.强调一点/符 号必须是花括号内第一个字符,也就算说{和/必须紧挨着。这对括号对上标和下标非常有用,但是对于 单词的重音符号就不好用了。对于这种字符最好使用特殊文本编码 iso 8859 1 or utf8 。这些字符集 里包含了大量有重音和附加其它标记的字符。产生空白可以使用 &{text} 它将产生与 text 等寬的空白。 'abc&{def}ghi' 生成 'abc ghi'. ~符号用于让下一个字符或者元素在同一水平位置输出,换句话说让他们重合,用于产生标注字符。 "~{abc}{1+++}" 加号提升 1 个单位。 "~{abc}{.7 ooo}" 小写 o 提升 0.7 个单位。 这个不美观。 "~a{1/*.5 o}" "~a{0/*1 o}" "~a{0/*2 o}" 小写 o 提升 1 个单位,尺寸减半。 小写 o 与小写 a 完全重合。 小写 o 放大一倍与 a 完全重合。 使用这个功能你可以组合出你想要的特殊符号。 你可以使用\XXX 访问字符,类似 c 语言中的表示方法,它直接表示字符编码值。 {/Symbol \245} 一个无穷的符号。但是这个方法在多字节编码的文档中工作不好,例如 utf8。这不 会造成什么限制,在 utf8 中你就直接输入这个字符就可以了。
分享到:
收藏