UNIX terminal commands GNUPLOT

#gnuplot
What … am I doing now? /
test / / help plot
gnuplot is case sensitive !
Test
p x / / p x w p
p x w lp
p [2:3] x
p[][1:5]
homework
p x w i
set samples 30
p x
p x w p ps 3
p x w l lt 3
p x w p ps 3
sp x*y / / Click on graph and drag!
set xlabel 'x'
show isosamples
set isosamples 30; replot
set contour ; replot
set cntrpar levels 40; replot
unset surface; replot
set view 0,0 ; replot
unset key ; replot
set pm3d ;
sp x*y / / unset surface; replot
help pm3d
set pm3d at s
splot 10*x with pm3d at b, x*x-y*y, \
x*x+y*y with pm3d at t
set palette model YIQ ; replot
help set palette
See the \ (backslash) at the end line.
Use a new gnuplot session: type gnuplot in the UNIX shell.
f(x)=x*sin(x)
p [1:20] f(x) / / See in the corner!
p [1:20][ 3:20] f(x)
p [1:20][ 0: ] f(x)
# there is nothing in the
# right side …. in [0 : ]
p [][ 0: ] f(x)
# there is nothing in[ ]
p [1:20] x>10?sin(x):x / / see the syntax:
condition ? YES : NO
f(x)= sin(x)<0.5? x : x**2
plot [1:10] f(x)
f(x)= sin(x)<0.5? x : 1/0
plot [1:10] f(x)
# This is a good trick!
# 1/0 is good thing!
set key left
set xlabel 'xx'
set title " line 1 \n line 2"
plot [1:10] f(x) t 'bla'
1) Use vi (or another editor) and put (copy-paste) the left side script.
2) Use the file name "aa" (without quotes).
3) #gnuplot aa / In the UNIX shell. Nothing happens.
4) # gv aa.ps or #evince aa.ps / or ghostview aa.ps
5) # ps2pdf aa.ps / Nothing happens.
6) # xpdf aa.pdf / This is a PDF file!!!
# set term postscript portrait enhanced color "Times-Bold" 12
set term postscript portrait enhanced color solid "Times-Bold" 12
set out 'aa.ps'
set multiplot
set size 0.5, 0.5
set origin 0.0, 0.5
pl x
set origin 0.0, 0.2
sp sin(x)/y
set nomultiplot
set multiplot
set size 0.3, 0.8
pl x
set nomultiplot / The first line is commented
multiplot  for many pages
set ____???____
is using in the next script lines !
Change the script and run the UNIX line:
#gnuplot aa; ps2pdf aa.ps; xpdf aa.pdf
# What is the following script?
i={0,1}; z(x,y)=x+y*i ; # Cartesian
f (z)=log(z)
sp real (f(z(x,y)))
# sp imag (f(z(x,y)))
# Whooooooo complex functions …..
THIS WILL BE THE FUN PART OF THE
STUDENT  PHYSICIST  RESEARCHER

Good examples for a good physicist. Practice at home.

???? / / / / function
/ / / derivative
# Copy and paste in GNUPLOT4 / f(z)=fi+i*psi
i={0,1}; z(x,y)=x+y*i ; # Cartesian
# f (z)=exp(z) # uncomment here
f (z)=log(z) # here is uncomment
set pm3d at s hidden3d 100
set style line 100 lt 5 lw 0.5
unset hidden3d ; unset surf;
set isosamples 50; set xlabel 'x'
psi(x,y) =imag (f(z(x,y))) ; # Imag part only
set grid layerdefault
set xrange [-5:5]; set yrange [-5:5]
sp psi(x,y) / i={0,1}; z(x,y)=x+y*i ; # Cartesian
# f (z)=exp(z) # uncomment here
f (z)=log(z) # here is uncomment
set pm3d at s hidden3d 100
set style line 100 lt 5 lw 0.5
unset hidden3d ; unset surf;
set isosamples 50; set xlabel 'x'
fi(x,y) =real (f(z(x,y))) ; # Real part only
set grid layerdefault
set xrange [-5:5]; set yrange [-5:5]
sp fi(x,y) / Graph on a rectangular domain
1)Uncomment ONLY one function (delete the sign # only in front the line).
2)Copy and paste in GNUPLOT4
3) Left-click on the graph and rotate it
set parametric # u=r, v=theta; # Polar
i={0,1}; z(u,v)=u*exp(i*v) ; # Polar
# f(z)=exp(z) # uncomment here
f(z)=log(z) # here is uncomment
set pm3d at s hidden3d 100
set style line 100 lt 5 lw 0.5
unset hidden3d ; unset surf;
set isosamples 50; set xlabel 'x'
psi(u,v) =imag (f(z(u,v))) ; # Imag part only
set grid layerdefault
set urange [0:5]; set vrange [-pi:pi]
sp u*cos(v),u*sin(v), psi(u,v) / set parametric # u=r, v=theta; # Polar
i={0,1}; z(u,v)=u*exp(i*v) ; # Polar
# f(z)=exp(z) # uncomment here
f(z)=log(z) # here is uncomment
set pm3d at s hidden3d 100
set style line 100 lt 5 lw 0.5
unset hidden3d ; unset surf;
set isosamples 50; set xlabel 'x'
fi(u,v) =real (f(z(u,v))) ; # Real part only
set grid layerdefault
set urange [0:5]; set vrange [-pi:pi]
sp u*cos(v),u*sin(v), fi(u,v) / Graph on a circular domain

In the physics world: hydrodynamics.

פונקצית Joukowsky , מתארת זרימה מסביב לגליל.

קווי זרימה. וקטור המהירות משיק לקו.
שים לב שעכשיו האזור המשורטט הוא מעגלי. / / # Copy and paste in GNUPLOT4
set parametric # u=r, v=theta; # Polar
i={0,1}; z(u,v)=u*exp(i*v) ; # Polar
R=4; v0=1; Joukowsky(z)=-v0*(z+R**2/z) ;
psi(u,v) = imag(Joukowsky(z(u,v))) ;
# fi(u,v) =-v0*(u+R**2/u)*cos(v) # If you wish
# psi(u,v) =-v0*(u-R**2/u)*sin(v) # If you wish
unset key; set isosamples 100
set cntrparam levels incremental -10, 0.1 , 10
set contour ; unset surface;
set view 0 ,360, 1.8 , 1.8
epsi=1.0e-6 # graphical trick
sp [R-epsi : 2.5*R][0:2*pi] u*cos(v), u*sin(v), psi(u,v)
השרטוט מכיל רק את קווי הזרימה מחוץ למעגל. המעגל ה- מתאר את הקיום של העמוד הגלילי ה- הנמצא בניצב לזרימה.
--- השרטט מתאר את הלחץ יחסית לערך שלו בנקודות הנמצאות באינסוף (ומנורמל ל- ). כלומר הפונקציה המסורטטת מתאימה לביטוי:
.
--- הערך המינימאלי נמצא במעגל (גליל) בכיוונים . הערך המכסימלי נמצא במעגל (גליל) בכיוונים .
--- קווי שווי הערך של הלחץ משורטטים גם כן. במקום שבו צפיפות הקווים גדולה יותר גרדיאנט (gradient) הלחץ גדול יותר. אין משמעות לצבע של הקווים. לעומת זאת יש משמעות לצבע של הרקע (למשל, כחול = מינימום של הלחץ). / / # Copy and paste in GNUPLOT4
set parametric # u=r, v=theta; # Polar
i={0,1}; z(u,v)=u*exp(i*v) ; # Polar
R=4; v0=1; Joukowsky(z)=-v0*(z+R**2/z) ;
vr(u,v) =-v0*(1-R**2/u**2)*cos(v)
vt(u,v) =+v0*(1+R**2/u**2)*sin(v)
Kpout(u,v)= (v0**2-vr(u,v)**2-vt(u,v)**2)/ v0**2
set pm3d # map
unset key
set isosamples 100
set cntrparam levels incremental -3, 0.25 , 1
set contour ; unset surface;
set view 0 ,360, 1.8 , 1.8
epsi=1.0e-6 # graphical trick
set cbrange [-3:1]
set palette defined ( 0 "blue", 1 "yellow", 2 "red" ) # preferred
set colorbox horiz user origin .4,.05 size .5,.04
# set colorbox vertical user origin .91,.5 size .03,.4
sp [R-epsi : 2.5*R][0:2*pi] u*cos(v), u*sin(v), Kpout(u,v) lt 3

Prof. Cezar Bruma Whoami_GNUPLOT.doc printed 11/28/2018