gnuplot 2007 7 11 gnuplot C 1 gnuplot gnuplot C gnuplot PGPLOT ROOT 2 2.1 gnuplot gnuplot 2D 3D gnu Free Software 1
Foundation (FSF) GNU 1 gnuplot ( ) gnuplot UNIX Windows Machintosh Excel Excel gnuplot C web http://t16web.lanl.gov/kawano/gnuplot/ http://lagendra.s.kanazawa-u.ac.jp/ogurisu/manuals/gnuplot-intro/ 2.2 web gnuplot $ gnuplot gnuplot gnuplot> exit 2.3 2 gnuplot> set samples 1024 1024 gnuplot> plot sin(x) sin gnuplot> plot [0:6.28] [-1.5:1.5] sin(x) gnuplot> plot [-6.28:6.28] [-1.5:1.5] sin(x),cos(x),tan(x) 1 Unix 2
gnuplot> plot x**3+x+1 x 3 + x + 1 gnuplot> plot x**0.5 x 0.5 gnuplot> plot log(x) log e (x) gnuplot> plot log10(x) log 10 (x) gnuplot> plot real(exp({0,1}*x)) R(e ix ) gnuplot> plot sqrt(x) x gnuplot> f(x)=sin(x) gnuplot> g(x)=cos(x) gnuplot> plot f(x)+g(x), f(x)*g(x) [ 1] sin(x) cos(x) sin 2 (x) sin(x) + cos(x) xe x x x3 6 + x5 120 x7 5040 cos(x), sin(x) gnuplot 2 gnuplot> {1,0} 1 gnuplot> {0,1} i gnuplot> {5.3,6.8} 5.3 + 6.8i 2.4 3 3 3 gnuplot> splot x**2+y**2 x 2 + y 2 gnuplot> splot x*sin(x+y) x sin(x + y) 3 set hidden3d set isosample x y 40 gnuplot> set hidden3d gnuplot> set isosample 40,40 gnuplot> splot 1/(x*x+y*y+5)*cos(0.1*(x*x+y*y)) 3
2.5 gnuplot> set parametric gnuplot> plot sin(5*t), cos(2*t+pi/2) gnuplot> set noeparametric 2.6 2 θ sin θ cos θ tan θ plot using x y gnuplot> plot "trifunc.txt" using 1:2 gnuplot> plot "trifunc.txt" using 1:2 with line gnuplot> plot "trifunc.txt" using 1:2 with line, "trifunc.txt" using 1:3 with line, "trifunc.txt" using 1:4 with line (Enter ) tan(x) set xrange[ymin:ymax] replot gnuplot> set yrange[-1.5:1.5] gnuplot> replot 2.7 2.7.1 gnuplot 1 2 http://www.akita-nct.jp/ yamamoto/lecture/2006/5e/gnuplot/trifunc.txt 4
gnuplot> set terminal emf gnuplot> set output "hogehoge.emf" emf hogehoge.emf 1: set terminal x11 windows emf postscript gif png epslatex UNIX Windows Windows UNIX web web L A TEX 2.7.2 MS word gnuplot MS Word Windows emf emf gnuplot> set terminal emf gnuplot> set output "hoge.emf" gnuplot> plot sin(x) emf hoge.emf emf hoge.emf MS Word Word emf 2.7.3 Starsuite Linux office Sun microsystems Starsuite Starsuite MS Word 5
2.7.4 L A TEX L A TEX L A TEX gnuplot> set terminal epslatex gnuplot> set output "hoge.eps" gnuplot> plot sin(x) hoge.eps hoge.tex L A TEX \documentclass[10pt,a4paper]{jarticle} \usepackage{graphicx} \begin{document} \begin{figure}[hbtp] \input{hoge} \caption{} \end{figure} \end{document} 3 gnuplot 3.1 gnuplot gnuplot> help gnuplot> help plot help web 3.2 gnuplot 3 6
3.3 gnuplot> pwd pwd cd gnuplot> cd "/home/yamamoto/hoge" gnuplot> cd ".." ( ) ( ) gnuplot> gnuplot>!ls! 4 C gnuplot 4.1 gnuplot C C gnuplot C gnuplot UNIX UNIX ( ) ( ) ls -l ls -l sort -n -k +5 ls -l sort -n -k +5 3 2 UNIX 3 man lsman sort f: b: q: 7
4.2 gnuplot C gnuplot C gnuplot (1) (2) (3) FILE *hoge; gnuplot hoge = popen("gnuplot -persist","w"); popen() gnuplot persist gnuplot gnuplot popen() gnuplot fprintf() fprintf(hoge, "plot sin(x)\n"); fprintf gnuplot C gnuplot Character-based User Interface(CUI) pclose(hoge); 4.3 4.3.1 C gnuplot 1 fprintf() gnuplot 1 #include <s t d i o. h> 2 3 int main ( void ){ 4 FILE gp ; 5 1: C gnuplot 8
6 gp = popen ( gnuplot p e r s i s t, w ) ; 7 f p r i n t f ( gp, p l o t s i n ( x )\ n ) ; 8 9 p c l o s e ( gp ) ; 10 11 return 0 ; 12 } 4.3.2 gnuplot 1. 21 plot - [ ] 2. 24 fprintf(, ) 3. e 27 fprintf(,"e\n") 2: 1 #include <s t d i o. h> 2 #include <math. h> 3 #define NX 720 4 5 int main ( void ){ 6 FILE gp ; 7 int i ; 8 double dx, x [NX+1], y [NX+1]; 9 10 / / 11 dx=4 M PI/NX; 12 for ( i =0; i<=nx; i ++){ 13 x [ i ]= 2 M PI+i dx ; 14 y [ i ]= s i n ( x [ i ] ) ; 15 } 16 17 / / 18 gp = popen ( gnuplot p e r s i s t, w ) ; 19 f p r i n t f ( gp, s e t xrange [ 6. 5 : 6. 5 ] \ n ) ; 20 f p r i n t f ( gp, s e t yrange [ 1. 5 : 1. 5 ] \ n ) ; 21 f p r i n t f ( gp, p l o t with l i n e s l i n e t y p e 1 t i t l e \ s i n \ \n ) ; 9
22 23 for ( i =0; i<=nx; i ++){ 24 f p r i n t f ( gp, %f \ t%f \n, x [ i ], y [ i ] ) ; // 25 26 } 27 f p r i n t f ( gp, e \n ) ; 28 29 p c l o s e ( gp ) ; 30 31 return 0 ; 32 } 4.3.3 3 27 plot " " [ ] 3: 1 #include <s t d i o. h> 2 #include <math. h> 3 #define NX 720 4 5 int main ( void ){ 6 FILE data, gp ; 7 char d a t a f i l e ; 8 int i ; 9 double dx, x, y ; 10 11 / / 12 d a t a f i l e= out. dat ; 13 data = fopen ( d a t a f i l e, w ) ; 14 15 dx=4 M PI/NX; 16 for ( i =0; i<=nx; i ++){ 17 x= 2 M PI+i dx ; 18 y=s i n ( x ) ; 19 f p r i n t f ( data, %f \ t%f \n, x, y ) ; 20 } 21 f c l o s e ( data ) ; 22 23 / / 24 gp = popen ( gnuplot p e r s i s t, w ) ; 25 f p r i n t f ( gp, s e t xrange [ 6. 5 : 6. 5 ] \ n ) ; 26 f p r i n t f ( gp, s e t yrange [ 1. 5 : 1. 5 ] \ n ) ; 27 f p r i n t f ( gp, p l o t \ %s \ with l i n e s l i n e t y p e 1 t i t l e \ s i n \ \n, d a t a f i l e ) ; 28 p c l o s e ( gp ) ; 29 30 return 0 ; 31 } 10
5 set 4 4: gnuplot 1 #include <s t d i o. h> 2 #include <math. h> 3 void m k t r i a n g l e d a t a ( char a, double x1, double x2, int n ) ; 4 void mk graph ( char f, char xlb, double x1, double x2, 5 char ylb, double y1, double y2 ) ; 6 7 / ========================================================== / 8 / main f u n c t i o n / 9 / ========================================================== / 10 int main ( void ){ 11 12 double p i = 4 atan ( 1 ) ; 13 14 m k t r i a n g l e d a t a ( out. t x t, 2 pi, 2 pi, 1 0 0 0 ) ; 15 mk graph ( out. t x t, x, 2 pi, 2 pi, y, 3, 3 ) ; 16 17 return 0 ; 18 } 19 20 / ========================================================== / 21 / make a data f i l e / 22 / ========================================================== / 23 void m k t r i a n g l e d a t a ( char a, double x1, double x2, int n ){ 24 double x, dx ; 25 double y1, y2, y3 ; 26 int i ; 27 FILE out ; 28 29 dx = ( x2 x1 )/ n ; 30 31 out = fopen ( a, w ) ; 32 33 for ( i =0; i<=n ; i ++){ 34 x = x1+dx i ; 35 y1 = s i n ( x ) ; 36 y2 = cos ( x ) ; 37 y3 = tan ( x ) ; 38 39 f p r i n t f ( out, %e \ t%e \ t%e \ t%e \n, x, y1, y2, y3 ) ; 40 } 41 42 f c l o s e ( out ) ; 43 } 44 45 / ========================================================== / 46 / make a graph / 47 / ========================================================== / 48 void mk graph ( char f, char xlb, double x1, double x2, 49 char ylb, double y1, double y2 ) 50 { 51 52 FILE gp ; 53 54 gp = popen ( gnuplot p e r s i s t, w ) ; 11
55 56 f p r i n t f ( gp, r e s e t \n ) ; 57 58 / s e t x g r i d / 59 60 f p r i n t f ( gp, s e t g r i d \n ) ; 61 62 / s e t x a x i s / 63 64 f p r i n t f ( gp, s e t x t i c s 1\n ) ; 65 f p r i n t f ( gp, s e t mxtics 10\n ) ; 66 f p r i n t f ( gp, s e t x l a b e l \ %s \ \n, xlb ) ; 67 f p r i n t f ( gp, s e t n o l o g s c a l e x\n ) ; 68 f p r i n t f ( gp, s e t xrange [%e:%e ] \ n, x1, x2 ) ; 69 70 / s e t y a x i s / 71 72 f p r i n t f ( gp, s e t y t i c s 1\n ) ; 73 f p r i n t f ( gp, s e t mytics 10\n ) ; 74 f p r i n t f ( gp, s e t y l a b e l \ %s \ \n, ylb ) ; 75 f p r i n t f ( gp, s e t n o l o g s c a l e y\n ) ; 76 f p r i n t f ( gp, s e t yrange [%e:%e ] \ n, y1, y2 ) ; 77 78 / p l a t graphs / 79 80 f p r i n t f ( gp, s e t t e r m i n a l x11 \n ) ; 81 82 f p r i n t f ( gp, p l o t \ %s \ u s i n g 1 : 2 with l i n e, \ 83 \ %s \ u s i n g 1 : 3 with l i n e, \ 84 \ %s \ u s i n g 1 : 4 with l i n e \n, f, f, f ) ; 85 86 f p r i n t f ( gp, s e t t e r m i n a l emf\n ) ; 87 f p r i n t f ( gp, s e t output \ t r i. emf\ \n ) ; 88 89 f p r i n t f ( gp, r e p l o t \n ) ; 90 91 p c l o s e ( gp ) ; 92 } 12
A A.1 gnuplot 2 2: gnuplot x z rz [1] abs(z) z ibeta(p,q,rz) acos(z) arccos(z) igamma(a,rz) acosh(z) arccosh(z) imag(z) z I(z) asin(z) arcsin(z) int(rz) rz asinh(z) arcshinh(z) inverf(rz) erf(rz) atan(z) arctan(z) invnorm(rz) norm(rz) atan2(z1,z2) ( π π) lgamma(rz) atanh(z) arctanh(z) log(z) log e (z) besj0(x) 0 J 0 (x) log10(z) log 10 (z) besj1(x) 1 J 1 (x) norm(rz) besy0(x) 0 Y 0 (x) rand(rz) eesy1(x) 1 Y 1 (x) real(z) z R(z) ceil(rz) z sgn(rz) R(z) cos(z) cos(z) sin(z) sin(z) cosh(z) cosh(z) sinh(z) sinh(z) erf(rz) ( ) erf(z) sqrt(z) z erfc(rz) 1 erf(z) tan(z) tan(z) exp(z) e z tanh(z) tanh(z) floor(rz) z gamma(rz) Γ(z r ) 13
A.2 gnuplot gnuplot 3 load "" 3: gnuplot [1] cd call clear exit fit help if load pause plot print pwd quit replot reread reset save set show shell splot test update ($n) GNUPLOT GNUPLOT GNUPLOT plot load set 3 fit 14
A.3 gnuplot (set) set show all rest 4 help web 4: gnuplot [2] angles missing x2label arrow mouse x2mtics autoscale scale multiplot x2range / bars mx2tics x2tics bmargin mxtics x2zeroaxis / border ( ) my2tics xdata boxwidth mytics xdtics cbdata mztics xlabel cbdtics offsets xmtics cblabel origin xrange / cbmtics output / xtics cbrange palette xzeroaxis / cbtics parametric y2data clabel pm3d 3 y2dtics clip pointsize y2label cntrparam polar y2mtics colorbox print y2range / contour rmargin y2tics datafile rrange / y2zeroaxis / date specifiers samples ydata decimalsign size ydtics dgrid3d 3 style ylabel dummy surface 3 ymtics encoding term yrange / fit terminal ytics fontpath tics yzeroaxis / format ticscale zdata grid ticslevel splot zdtics hidden3d time zero historysize time specifiers zeroaxis / isosamples 3 timefmt zlabel key timestamp zmtics label title zrange / lmargin tmargin ztics loadpath trange / locale urange / log log view 3 logscale vrange / mapping 3 x2data margin x2dtics 15
B gnuplot e ( 4 ) 5: 1 #include <s t d i o. h> 2 #include <math. h> 3 #define NX 720 4 5 int main ( void ){ 6 FILE gp ; 7 int i ; 8 double dx, x [NX+1], y1 [NX+1], y2 [NX+1], y3 [NX+1]; 9 10 / / 11 dx=4 M PI/NX; 12 for ( i =0; i<=nx; i ++){ 13 x [ i ]= 2 M PI+i dx ; 14 y1 [ i ]= s i n ( x [ i ] ) ; 15 y2 [ i ]= cos ( x [ i ] ) ; 16 y3 [ i ]= tan ( x [ i ] ) ; 17 } 18 19 / / 20 gp = popen ( gnuplot p e r s i s t, w ) ; 21 f p r i n t f ( gp, s e t xrange [ 6. 5 : 6. 5 ] \ n ) ; 22 f p r i n t f ( gp, s e t yrange [ 1. 5 : 1. 5 ] \ n ) ; 23 f p r i n t f ( gp, p l o t with l i n e s l i n e t y p e 1 t i t l e \ s i n \,\ 24 with l i n e s l i n e t y p e 2 t i t l e \ cos \,\ 25 with l i n e s l i n e t y p e 3 t i t l e \ tan \ \n ) ; 26 27 / ( s i n ) / 28 for ( i =0; i<=nx; i ++){ 29 f p r i n t f ( gp, %f \ t%f \n, x [ i ], y1 [ i ] ) ; 30 } 31 f p r i n t f ( gp, e \n ) ; 32 33 / 2 ( cos ) / 34 for ( i =0; i<=nx; i ++){ 35 f p r i n t f ( gp, %f \ t%f \n, x [ i ], y2 [ i ] ) ; 36 } 37 f p r i n t f ( gp, e \n ) ; 38 39 / 3 ( tan ) / 40 for ( i =0; i<=nx; i ++){ 41 f p r i n t f ( gp, %f \ t%f \n, x [ i ], y3 [ i ] ) ; 42 } 43 f p r i n t f ( gp, e \n ) ; 44 45 p c l o s e ( gp ) ; 46 47 return 0 ; 48 } 16
C C.1 Windows Windouws gnuplot wgnuplot wgnuplot UNIX C.2 Windous UNIX 5 Windows C gnuplot 5: gnuplot UNIX Windous UNIX Windos popen popen pcluse pclose gnuplot pgnuplot.exe -persist pause -1 [1] Gnuplot reference. http://plum.nak.nw.kanagawa-it.ac.jp/docs/latex/gnuplot-reference/. [2] http://t16web.lanl.gov/kawano/gnuplot/set.html. 17