gnulpot
gnulpot
Table of Contents
- 1. Label position
- 2. coordinates
- 3. Symbols
- 4. key
- 5. FAQ
- 6. PLotting with error bar
- 7. Plotting data with points
- 8. References
- 9. Introduction
- 10. Comments
- 11. Terminal
- 12. Syntax:
- 13. load scripts in Linux
- 14. gnuplot on Windows
- 15. X11
- 16. line types
- 17. line style and arrow
- 18. Example
- 19. Output
- 20. sine wave
- 21. Abbreviation
- 22. tutorials
- 23. log
1 Label position
e.g. set label 1 'interaural time differences' at -15,0.85 front right at -15, 0.85
position coordinate, x=-15, y=0.85 position is specified by either x,y or x,y,z (coordinates), and may be preceded by first, second, graph, screen, or character to select the coordinate system. See 2 for details.
2 coordinates
coordinates in official web Syntax:
- {<system>} <x>, {<system>} <y> {,{<system>} <z>}
- system can either be first, second, graph, screen, or character.
- places the x, y, or z coordinate in the system defined by the left and bottom axes
e.g. set key at first 2, 5
- second
- places it in the system defined by the second axes (top and right)
- graph
- specifies the area within the axes
- 0,0 is bottom left and 1,1 is top right (for splot, 0,0,0 is bottom left of plotting area; use negative z to get to the base – see set ticslevel
e.g. set key at graph .5, .5
# set the key at the middle of the graph
3 Symbols
keywords: enhanced text mode
~U{0.8-}
## \( \overline{U} \)
U{/Symbol \245}
#U∞
{/Symbol \245}
#∞, infinity
{/Symbol q}
# θ {/Symbol q}_R = 0^{0}
θR=0\degree
Symbol and alphabet is as follows.
ALPHABET | SYMBOL | ALPHABET | SYMBOL | alphabet | symbol | alphabet | symbol |
A Alpha N Nu a alpha n nu B Beta O Omicron b beta o omicron C Chi P Pi c chi p pi D Delta Q Theta d delta q theta E Epsilon R Rho e epsilon r rho F Phi S Sigma f phi s sigma G Gamma T Tau g gamma t tau H Eta U Upsilon h eta u upsilon I iota W Omega i iota w omega K Kappa X Xi k kappa x xi L Lambda Y Psi l lambda y psi M Mu Z Zeta m mu z zeta
^ | ax superscript | |
_ |
ax | subscript |
@ | @x or a@bc | phantom box (occupies no width) |
& | &{space} | inserts space of specified length |
~ | ~a{.8-} | overprints '-' on 'a', raised by .8 |
http://materials.ucsd.edu/doc/ps_guide.pdf
Control Example Result Explanation
@ | a@bcd ab |
cd phantom box (occupies no width) & d&{space}b d b inserts space of specilized length ~ ~a{.8-} ~a overprints '-' on 'a', raised by .8 times the current fontsize {/Times abc} abc print abc in font Times at current size {/Times*2 abc} abc print abc in font Times at twice current size {/Times:Italic abc} abc print abc in font Times with style italic
4 key
4.1 key position
> set key out horiz center top ## key outside, horizontal, center ,top e.g.
key out vertical centra right > set key right > set key outside right bottom vertical Right noreverse enhanced autotitles box linetype -1 linewidth 1.000 > set title "Key (out vert cent right)" http://gnuplot.sourceforge.net/demo_4.4/key.html
set key at graph .7, .9 top right,
4.2 gnuplot legend overlaps graph
key=legend
4.3 key
key=legend the set key
command enables a key (or legend) containing a title and a sample (line, point, box) for each plot in the graph. set key top left
4.3.1 syntax
set key {on|off} {default} {{inside | outside} | {lmargin | rmargin | tmargin | bmargin}
{at <position>}} |
{left | right | center} {top | bottom | center} {vertical | horizontal} {Left | Right} {{no}opaque} {{no}reverse} {{no}invert} {samplen <samplelength>} {spacing <verticalspacing>} {width <widthincrement>} {height <heightincrement>} {{no}autotitle {columnheader}} {title "<text>"} {{no}enhanced} {font "<face>,<size>"} {textcolor <colorspec>} {{no}box {linestyle <style> | linetype <type> | linewidth <width>}} {maxcols {<max no. of columns> | auto}} {maxrows {<max no. of rows> | auto}}
5 FAQ
5.1 Zooming in with multiplot
5.1.1 code
#!/usr/bin/gnuplot
reset
set terminal wxt size 350,262 enhanced font 'Verdana,10' persist
#set terminal pngcairo size 350,262 enhanced font 'Verdana,10' #set output 'zoomplot.png'
set style line 2 lc rgb '#0025ad' lt 1 lw 2 set style line 3 lc rgb '#0042ad' lt 1 lw 2 set style line 4 lc rgb '#0060ad' lt 1 lw 2 set style line 5 lc rgb '#007cad' lt 1 lw 2 set style line 6 lc rgb '#0099ad' lt 1 lw 2 set style line 7 lc rgb '#00ada4' lt 1 lw 2 set style line 8 lc rgb '#00ad88' lt 1 lw 2 set style line 9 lc rgb '#00ad6b' lt 1 lw 2 set style line 10 lc rgb '#00ad4e' lt 1 lw 2 set style line 11 lc rgb '#00ad31' lt 1 lw 2 set style line 12 lc rgb '#00ad14' lt 1 lw 2 set style line 13 lc rgb '#09ad00' lt 1 lw 2
unset key
set style line 101 lc rgb '#808080' lt 1 set border 3 back ls 101 set tics nomirror out scale 0.75
set style line 102 lc rgb'#808080' lt 0 lw 1 set grid back ls 102
set format x '%g°' set xlabel 'azimuth angle' set ylabel 'time / ms' offset 1,0
set xrange [-90:0] set yrange [0:0.9]
set label 1 'interaural time differences' at -15,0.85 front right set label 2 'f = 236Hz' at -28,0.45 textcolor ls 2 set label 3 'f = 1296Hz' at -12,0.05 right textcolor ls 13
set multiplot
set object 1 rect from -88,0.03 to -49,0.41 set object 1 rect fc rgb 'white' fillstyle solid 0.0 noborder plot for [n=2:13] 'itd.txt' u 1:(column(n)*1000) w lines ls n
do for [n=2:13] { set style line n lw 1 } set origin 0.12,0.17 set size 0.45,0.4 set xrange [-10:0] set yrange [0:0.1] unset xlabel unset ylabel unset label unset object 1 set tics scale 0.5 front set xtics 10 offset 0,0.5 set ytics 0.1 offset 0.5,0 plot for [n=2:13] 'itd.txt' u 1:(column(n)*1000) w lines ls n
unset multiplot
6 PLotting with error bar
plot "e387bem/eppexp.dat" t "luznik-exp" with errorbars ,\
"e387exp/Cpnowavee387luznik95CI.dat" with errorbars notitle,\ "e387exp/Cpnowavee387luznik95CI.dat" using 1:2 pt 2 t "Exp95%CI",\
https://stackoverflow.com/questions/10684182/gnuplot-with-errorbars-plotting
6.1 Data
syntax: (x, y, ydelta)
4.5 0.38 0.048 5.0 0.39 0.048 5.5 0.37 0.046 6.0 0.33 0.041 6.5 0.30 0.038 7.0 0.27 0.031 7.5 0.23 0.028 8.0 0.18 0.023 8.5 0.125 0.018
7 Plotting data with points
data file
# plotting_data1.dat
# X Y
1 2
2 3
set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 7 ps 1.5 # — blue plot 'plottingdata1.dat' with linespoints ls 1
pt
point typeps
point size
8 References
9 Introduction
command-line graphing It was originally created to allow scientists and students to visualize mathematical functions and data interactively
Command language is case sensitve,i.e. commands and function names written in lowercase are not the same as those written in capitals
commands in a line must be separated by semicolon(;)
Strings can be either single or double quotes
i.e.
/set title "my first plot"; plot 'data'; print "all done!"/
{} #optional choice
\| #separates mutually exclusive choice
<> #mark replaceable tokens
10 Comments
#, comment
Comments are supported as follows: a # may appear in most places in a line and gnuplot will ignore the rest of the line.
It will not have this effect inside quotes, inside numbers (including complex numbers), inside
command substitutions, etc. In short, it works anywhere it makes sense to work.
See also set datafile commentschars (p. 109) for specifying comment characters in data files.
Note that if a comment line ends in '\' then the subsequent line is also treated as a comment.
11 Terminal
11.1 postscript
set terminal postscript eps enhanced color font 'Helvetica,10' size 3in, 3in
~set output 'introduction.eps'~
Besides, the postscript terminal can’t handle all UTF-8 input characters and we have to use the enhanced mode to produce greek letter etc. But in opposite to the before mentioned terminals the enhanced mode will work fully for the postscript terminal.
set xlabel '{/Helvetica-Oblique x}'
set ylabel '{/Helvetica-Oblique y}'
set xtics ('-2{/Symbol p}' -2*pi,'-{/Symbol p}' -pi,0, \
'{/Symbol p}' pi,'2{/Symbol p}' 2*pi)
plot f(x) title 'sin({/Helvetica-Oblique x})' with lines linestyle 1, \
11.1.1 syntax
set terminal postscript {default}
set terminal postscript {landscape | portrait | eps}
{enhanced | noenhanced}
{defaultplex | simplex | duplex}
{fontfile [add | delete] "<filename>"| nofontfiles} {{no}adobeglyphnames}
{level1 | leveldefault | level3}
{color | colour | monochrome}
{background <rgbcolor> | nobackground}
{dashlength | dl <DL>}
{linewidth | lw <LW>}
{rounded | butt}
{clip | noclip}
{palfuncparam <samples>{,<maxdeviation>}}
{size <XX>{unit},<YY>{unit}}
{blacktext | colortext | colourtext}
{{font} "fontname{,fontsize}" {<fontsize>}}
{fontscale <scale>}
11.2 pdf
11.2.1 test
gnuplot> set terminal pdf monochrome
gnuplot> set output "graph.pdf"
gnuplot> test
gnuplot> unset output
- not recommended
set terminal pdf {monochrome|color|colour} {{no}enhanced} {fname "<font>"} {fsize <fontsize>} {font "<fontname>{,<fontsize>}"} {fontscale <scale>} {linewidth <lw>} {rounded|butt} {dl <dashlength>}} {size <XX>{unit},<YY>{unit}} The default is to use a different color for each line type. Selecting monochome will use black for all linetypes, Even in in mono mode you can still use explicit colors for filled areas or linestyles.
where <font> is the name of the default font to use (default Helvetica) and <fontsize> is the font size (in points, default 12). For help on which fonts are available or how to install new ones, please see the documentation for your local installation of pdflib.
The enhanced option enables enhanced text processing features (subscripts, superscripts and mixed fonts). See enhanced.
The width of all lines in the plot can be increased by the factor <n> specified in linewidth. Similarly dashlength is a multiplier for the default dash spacing.
rounded sets line caps and line joins to be rounded; butt is the default, butt caps and mitered joins.
The default size for PDF output is 5 inches by 3 inches. The size option changes this to whatever the user requests. By default the X and Y sizes are taken to be in inches, but other units are possible (currently only cm).
12 Syntax:
set terminal {<terminal-type> | push | pop} show terminal
If <terminal-type> is omitted, gnuplot will list the available terminal types. <terminal-type> may be abbreviated. If both set terminal and set output are used together, it is safest to give set terminal rst, because some terminals set a ag which is needed in some operating systems.
13 load scripts in Linux
script is suffix with script.gnu
To load a script:
> load "sample.gnu"
14 gnuplot on Windows
14.1 change directory
~cd 'C:\Users\exw692\Documents\gnuplot'~
- use single quote for directory
15 X11
gnuplot provides the x11 terminal type for use with X servers. This terminal type is set automatically at startup if the DISPLAY environment variable is set, if the TERM environment variable is set to xterm, or if the -display command line option is used. Syntax: set terminal x11 {<n>} {title "<string>"} {{no}enhanced} {font <fontspec>} {{no}persist} {{no}raise} {solid|dashed} {{no}ctrlq} {close} set terminal x11 {reset}
Autoscaling may be set individually on the x, y or z axis or globally on all axes. The default is to autoscale all axes. If you want to autoscale based on a subset of the plots in the figure, you can mark the other ones with the flag noautoscale. See data file (p. 78). Syntax: set autoscale {<axes>{|min|max|fixmin|fixmax|fix} | fix | keepfix} unset autoscale {<axes>} show autoscale where <axes> is either x, y, z, cb, x2, y2 or xy. A keyword with min or max appended (this cannot be done with xy) tells gnuplot to autoscale just the minimum or maximum of that axis. If no keyword is given, all axes are autoscaled.
Plotting plot generates 2D plots, splot generates 3D plots (actually 2D projections, of course
16 line types
the postscript terminal shows different dash patterns: type the following commands, and you will see the line types in an image named "test"
- linestyle
- user defined line style
- linetype
- system defined
set terminal postscript eps color colortext
set output 'test.eps'
test
set output
16.1 dashed line
- depends on selectd terminal
- png don't support dashed lines
- pngcairo, support dashed lines, but it is disables by default. To enable it, use set termoption dashed, or set terminal pngcairo dashed ….
- To see the defined linetype, use the test command:
++ set terminal pngcairo dashed set output 'test.png' test set output ++
16.2 line with points
set style line 1 linecolor rgb "red" linewidth 1.000 lt 1 pointtype 1 plot "e387bem/fort.101" using 1:2 t "TSR 1" ls 1 with linespoints
17 line style and arrow
17.1 Syntax:
set style line <index> default set style line <index> {{linetype | lt} <linetype> | <colorspec>} {{linecolor | lc} <colorspec>} {{linewidth | lw} <linewidth>} {{pointtype | pt} <pointtype>} {{pointsize | ps} <pointsize>} {{pointinterval | pi} <interval>} {{dashtype | dt} <dashtype>} {palette} unset style line show style line
17.2 example
set style line 1 lt 1 lc rgb "black" lw 1
lc
line color lw
line width http://gnuplot.sourceforge.net/demo_5.0/lines_arrows.html
17.3 pointinterval
18 Example
18.1 Eldad Avital
#set terminal jpeg #set output 'airfoile387bluntsharp.pdf' set terminal postscript eps enhanced color font 20 size 3in, 3in set out 'airfoile387bluntsharp.eps' #set terminal X11 set autoscale unset log unset label unset pm3d set key at graph .8, .9 set key spacing 1.2 set xtic auto set ytic auto set xlabel "x/R" set xrange [*:1]
set yrange [*:*] set ylabel "y/c set style line 1 lt 1 lc rgb "black" lw 1
set style line 2 lt 2 lc rgb "red" lw 4
set style line 3 lt 3 lc rgb "purple" lw 3 set style line 4 lt 4 lc rgb "blue" lw 3 set style line 5 lt 5 lc rgb "black" lw 2 set style line 6 lt 6 lc rgb "brown" lw 3 plot "2de287sharp.txt" using 1:2 t "E387 sharp" ls 1 with lines,\ "2de387bluntcoor.txt" using 1:2 t "E387 blunt" ls 2 with lines
18.2 Join data points with non-continuous lines
18.3 case 2
set terminal pngcairo size 350,262.5 enhanced font 'Verdana,10' set output 'terminalpng.png'
set border linewidth 1.5 set style line 1 linecolor rgb '#0060ad' linetype 1 linewidth 2 # blue set style line 2 linecolor rgb '#dd181f' linetype 1 linewidth 2 # red
set key at 6.1,1.3
set xlabel 'x' set ylabel 'y'
set xrange[-2*pi:2*pi] set yrange[-1.5:1.5]
set xtics ("-2Ï€" -2*pi, "-Ï€" -pi, 0, "Ï€" pi, "2Ï€" 2*pi) set ytics 1 set tics scale 0.75
a = 0.9 f(x) = a * sin(x) g(x) = a * cos(x)
plot f(x) title 'sin(x)' with lines ls 1, \ g(x) notitle with lines ls 2
19 Output
By default, screens are displayed to the standard output. The set output command redirects the display to the specified file or device.
Syntax: set output {"<filename>"} show output The filename must be enclosed in quotes, e.g.
set output 'model.jpeg'
Plotting Functions Basic Plotting1
20 sine wave
sin wave plotting Radians is used for trigonometric functions xlabel:label for X axis For the Greek symbols the terminal's "enhanced" option must be used. This is done in the set terminal command. xtic: marker on the x-axis The xzeroaxis command draws a horizontal line along the zero value on the Y axis (parallel to the X axis). Example ~# Clear any previous plots. clear
reset
set key off
set title "Sine against Phase"
set xrange [0:6.28]
set xlabel "Phase (radians)"
set xtics ("0" 0,"0.5{/Symbol p}" pi/2, "{/Symbol p}" pi, \ "1.5{/Symbol p}" 1.5*pi, "2{/Symbol p}" 2*pi)
set xzeroaxis
set yrange [-1:1]
unset ytics
set terminal wxt enhanced
plot sin(x)~
21 Abbreviation
lt #line type lc #line color lw # line width
23 log
line type and point type not compatiable Warning: No pointtype specifier allowed, here
Footnotes:
https://www.cs.hmc.edu/~vrable/gnuplot/using-gnuplot.html
In gnuplot, exponentiation uses **, not ^.
From
gnulpot的更多相关文章
随机推荐
- Django的CBV方式讲解
CBV使用配置 路径url的配置 cbv 顾名知义就是通过类的方法来调用,我们在url中配置为如下路径 url(r'^cbv.html/', views.Cbv.as_view()), 这里的Cbv是 ...
- STM32: TIMER门控模式控制PWM输出长度
搞了两天单脉冲没搞定,无意中发现,这个利用主从模式的门控方式来控制一路PWM的输出长度很有效. //TIM2 PWM输出,由TIM4来控制其输出与停止 //frequency_tim2:TIM2 PW ...
- CodeForces 382C Arithmetic Progression (排序+分类讨论)
题意:给出一个长度为n的序列,表示有n张卡片,上面的数字,现在还有一张卡片,上面没有数字,问说可以写几种数字在这张卡片上面, 使得n+1张卡片上的数字可以排列成一个等差数列,有无限多种时输出-1. 析 ...
- codemirror插件-文件比较组件merge
目的: 为了实现文件比较功能 引用文件 从github下载项目后,从以下路径引用文件,其中部分github分支中codemirror.js 需要运行项目,自动合成 <link rel=style ...
- StackOverflow 创始人关于如何高效编程的清单
这是 StackOverflow 联合创始人 Jeff Atwood 注释的十戒.程序员普遍有很强的自尊心,都应该看看本文,打印下来时刻提醒自己. “无我编程”发生在开发阶段,表现为技术团队经常通过同 ...
- 探寻宝藏 --- 双线DP
双线DP , 在郑轻的时候 做过 这种双线DP , 这是多维DP 应该是比较简单的 但是那个 时间复杂度的优化 始终看不懂 . 先附上代码吧 , 等看懂了再来 , 补充一下 解释 . #in ...
- [C陷阱和缺陷] 第7章 可移植性缺陷
C语言在许多不同的系统平台上都有实现.的确,使用C语言编写程序的一个首要原因就是,C程序能够方便地在不同的编程环境中移植. 不同的系统有不同的需求,因此我们应该能够预料到,机器不同则其上的C语 ...
- 贪心 UVA 11729 Commando War
题目传送门 /* 贪心:按照执行时间长的优先来排序 */ #include <cstdio> #include <algorithm> #include <iostrea ...
- 解决:阿里云ECS上启动tomcat后,第一次访问时间特别长
Re在ECS上启动tomcat后,第一次访问时间特别长 2017-04-25 10:16:04 INFO com.world.socket.ServerSocketListener 25- ...
- python批量删除文件夹
制作的python程序跑一次就占200多内存在temp下面,关键是还不释放,最开始都没有发现这个问题,知道自己的c盘越来越小才发现问题所在.所以就有了去删除temp下生成的文件 代码如下: impor ...