Pomoč:Gnuplot

Iz E-študij, proste zakladnice študentskega znanja

Skoči na: navigacija, iskanje
Orodje za risanje 2D in 3D grafov

http://en.wikipedia.org/wiki/Wikipedia:How_to_create_graphs_for_Wikipedia_articles

Vsebina

Številski zapis

<gnuplot>
set size 0.5,0.5
plot [-1:1] [-0.5:0.5] 1/4
</gnuplot>

cela/realna

<gnuplot>
set size 0.5,0.5
plot [-1:1] [-0.5:0.5] 1./4
</gnuplot>

Gnuplot Plot

Gnuplot Plot

Funkcije

Funkcije

  • lt .. izbira serije pik
  • lw .. debelina pike
  • linesp .. poveži pike

Na voljo je tona demotov za igranje. Zadeva obsega vse od simple plottanja do celega programskega orodja za zahtevna preračunavanja. --B-D_ 21:55, 7 oktober 2006 (BST)

zapis števil

Eksponentno
3e4
3\cdot 10^4

Operatorji

seštevanje, odštevanje

a+b\qquad a-b dobimo z:

a+b, a-b
množenje, deljenje

a \cdot b\qquad \frac{a}{b} dobimo z:

a*b, a/b
potenciranje
a^b\,\! dobimo z:
a**b

Nekaj funkcij

info grafa

unset border

Gnuplot Plot

unset border
<gnuplot>
set size 0.5,0.5
unset border
plot [-pi:pi][-1:1] sin(x), cos(x)
</gnuplot>

no_tics

Gnuplot Plot

set noytics
<gnuplot>
set size 0.5,0.5
set noytics
plot [-pi:pi][-1:1] sin(x), cos(x)
</gnuplot>

Gnuplot Plot

set noxtics
<gnuplot>
set size 0.5,0.5
set noxtics
plot [-pi:pi][-1:1] sin(x), cos(x)
</gnuplot>

unset key

Gnuplot Plot

unset key
<gnuplot>
set size 0.5,0.5
unset key
plot [-pi:pi][-1:1] sin(x), cos(x)
</gnuplot>

_tics nomirror

Gnuplot Plot

set xtics nomirror
<gnuplot>
set size 0.5,0.5
set xtics nomirror
plot [-pi:pi][-1:1] sin(x), cos(x)
</gnuplot>


Gnuplot Plot

set ytics nomirror
<gnuplot>
set size 0.5,0.5
set ytics nomirror
plot [-pi:pi][-1:1] sin(x), cos(x)
</gnuplot>

_label

Gnuplot Plot

set xlabel
<gnuplot>
set size 0.5,0.5
set xlabel "x os"
plot [-pi:pi][-1:1] sin(x), cos(x)
</gnuplot>

Gnuplot Plot

set ylabel
<gnuplot>
set size 0.5,0.5
set ylabel "y os"
plot [-pi:pi][-1:1] sin(x), cos(x)
</gnuplot>

lines

Gnuplot Plot

set xzeroaxis
<gnuplot>
set title "od tocke do tocke: lines"
plot '-' using 1:2 t '' with lines
1 3
3 7
4 16
e
</gnuplot>


Gnuplot Plot

set xzeroaxis
<gnuplot>
set title "od tocke do tocke: linesp"
plot '-' using 1:2 t '' with linesp
1 3
3 7
4 16
e
</gnuplot>

_zerosaxis

Gnuplot Plot

set xzeroaxis
<gnuplot>
set size 0.5,0.5
set xzeroaxis
plot [-pi:pi][-1:1] sin(x), cos(x)
</gnuplot>

Gnuplot Plot

set yzeroaxis
<gnuplot>
set size 0.5,0.5
set yzeroaxis
plot [-pi:pi][-1:1] sin(x), cos(x)
</gnuplot>

logscale

Gnuplot Plot

set title "set logscale x"
dbmag(x) = 20*(-log10(sqrt(1 + x**2))+2*log10(sqrt(1+(x/50)**2))-log10(sqrt(1+(x/100)**2)))
set logscale x
plot[x=1e-1:1e4] dbmag(x)

multi-plot

Gnuplot lahko nariše več kot en graf v okno ( kot subplot v matlabu )

set multiplot;                          # get into multiplot mode
set size 1,0.5;  
set origin 0.0,0.5;   plot sin(x); 
set origin 0.0,0.0;   plot cos(x)
unset multiplot                         # exit multiplot mode

Gnuplot Plot

set arrow

set arrow 1 from -A,0 to A,0
set arrow 2 from 0,-M to 0,M

priprava funkcij za risanje

Funkcije
  • Binv(p,q)=exp(lgamma(p+q)-lgamma(p)-lgamma(q))
  • arcsin(x)=invpi/sqrt(r*r-x*x)
  • beta(x)=Binv(p,q)*x**(p-1.0)*(1.0-x)**(q-1.0)
  • bin_s(x)=n!/(n-int(x))!/int(x)!*p**int(x)*(1.0-p)**(n-int(x))
  • bin_l(x)=exp(lgamma(n+1)-lgamma(n-int(x)+1)-lgamma(int(x)+1)+int(x)*log(p)+(n-int(x))*log(1.0-p))
  • binom(x)=(n<20)?bin_s(x):bin_l(x)
  • cauchy(x)=b/(pi*(b*b+(x-a)**2))
  • chi(x)=exp((0.5*df1-1.0)*log(x)-0.5*x-lgamma(0.5*df1)-df1*0.5*log2)
  • erlang(x)=lambda**n/(n-1)!*x**(n-1)*exp(-lambda*x)
  • extreme(x)=alpha*(exp(-alpha*(x-u)-exp(-alpha*(x-u))))
  • f(x)=Binv(0.5*df1,0.5*df2)*(df1/df2)**(0.5*df1)*x**(0.5*df1-1.0)/(1.0+df1/df2*x)**(0.5*(df1+df2))
  • g(x)=exp(rho*log(lambda)+(rho-1.0)*log(x)-lgamma(rho)-lambda*x)
  • geometric(x)=exp(log(p)+int(x)*log(1.0-p))
  • halfnormal(x)=sqrt2invpi/sigma*exp(-0.5*(x/sigma)**2)
  • hypgeo(x)=(int(x)>mm||int(x)<mm+n-nn)?0:mm!/(mm-int(x))!/int(x)!*(nn-mm)!/(n-int(x))!/(nn-mm-n+int(x))!*(nn-n)!*n!/nn!
  • laplace(x)=0.5/b*exp(-abs(x-a)/b)
  • logistic(x)=lambda*exp(-lambda*(x-a))/(1.0+exp(-lambda*(x-a)))**2
  • lognormal(x)=invsqrt2pi/sigma/x*exp(-0.5*((log(x)-mu)/sigma)**2)
  • maxwell(x)=fourinvsqrtpi*a**3*x*x*exp(-a*a*x*x)
  • negbin(x)=exp(lgamma(r+int(x))-lgamma(r)-lgamma(int(x)+1)+r*log(p)+int(x)*log(1.0-p))
  • nexp(x)=lambda*exp(-lambda*x)
  • normal(x)=invsqrt2pi/sigma*exp(-0.5*((x-mu)/sigma)**2)
  • pareto(x)=x<a?0:b/x*(a/x)**b
  • poisson(x)=mu**int(x)/int(x)!*exp(-mu)
  • rayleigh(x)=lambda*2.0*x*exp(-lambda*x*x)
  • sine(x)=2.0/a*sin(n*pi*x/a)**2
  • t(x)=Binv(0.5*df1,0.5)/sqrt(df1)*(1.0+(x*x)/df1)**(-0.5*(df1+1.0))
  • triangular(x)=1.0/g-abs(x-m)/(g*g)
  • uniform(x)=1.0/(b-a)
  • weibull(x)=lambda*n*x**(n-1)*exp(-lambda*x**n)
  • carcsin(x)=0.5+invpi*asin(x/r)
  • cbeta(x)=ibeta(p,q,x)
  • cbinom(x)=ibeta(n-x,x+1.0,1.0-p)
  • ccauchy(x)=0.5+invpi*atan((x-a)/b)
  • cchi(x)=igamma(0.5*df1,0.5*x)
  • cerlang(x)=1.0-exp(-lambda*x)*(1.0+lambda*x+0.5*(lambda*x)**2)
  • cextreme(x)=exp(-exp(-alpha*(x-u)))
  • cf(x)=1.0-ibeta(0.5*df2,0.5*df1,df2/(df2+df1*x))
  • cgamma(x)=igamma(rho,x)
  • cgeometric(x)=(x<1)?geometric(0):geometric(x)+cgeometric(x-1)
  • chalfnormal(x)=erf(x/sigma/sqrt2)
  • chypgeo(x)=(x<1)?hypgeo(0):hypgeo(x)+chypgeo(x-1)
  • claplace(x)=(x<a)?0.5*exp((x-a)/b):1.0-0.5*exp(-(x-a)/b)
  • clogistic(x)=1.0/(1.0+exp(-lambda*(x-a)))
  • clognormal(x)=cnormal(log(x))
  • cnormal(x)=0.5+0.5*erf((x-mu)/sigma/sqrt2)
  • cmaxwell(x)=igamma(1.5,a*a*x*x)
  • cnegbin(x)=(x<1)?negbin(0):negbin(x)+cnegbin(x-1)
  • cnexp(x)=1.0-exp(-lambda*x)
  • cpareto(x)=x<a?0:1.0-(a/x)**b
  • cpoisson(x)=1.0-igamma(x+1.0,mu)
  • crayleigh(x)=1.0-exp(-lambda*x*x)
  • csine(x)=x/a-sin(n*twopi*x/a)/(n*twopi)
  • ct(x)=(x<0.0)?0.5*ibeta(0.5*df1,0.5,df1/(df1+x*x)):1.0-0.5*ibeta(0.5*df1,0.5,df1/(df1+x*x))
  • ctriangular(x)=0.5+(x-m)/g-(x-m)*abs(x-m)/(2.0*g*g)
  • cuniform(x)=(x-a)/(b-a)
  • cweibull(x)=1.0-exp(-lambda*x**n)
Konstante
  • fourinvsqrtpi = 2.25675833419103
  • invpi = 0.318309886183791
  • invsqrt2pi = 0.398942280401433
  • log2 = 0.693147180559945
  • sqrt2 = 1.4142135623731
  • sqrt2invpi = 0.797884560802865
  • twopi = 6.28318530717959
  • a = 1.0
  • alpha = 0.5
  • b = 2.0
  • df1 = 1
  • df2 = 1
  • g = 1.0
  • lambda = 1.20919957615615
  • m = 0.0
  • mm = 25
  • mu = 5.0
  • nn = 75
  • n = 10
  • p = 0.4
  • q = 0.5
  • r = 8
  • rho = 3.2
  • sigma = 2.23606797749979
  • u = 1.0
  • xmin = 0
  • xmax = 14
  • ymax = 0.193014106744636
  • xinc = 1

Primeri

Legendrovi polinomi

Gnuplot Plot

<gnuplot>
set size 0.3, 0.3
set yrange [-4: 4]
set xzeroaxis
unset border
unset key
set xtics nomirror
set ytics nomirror

P0(x) = 1
P1(x) = x
P2(x) = 3*x**2 - 1
P3(x) = 5*x**3 - 3*x
P4(x) = 35*x**4 - 30*x**2 + 3

plot [-1: 1] P0(x),P1(x), P2(x), P3(x), P4(x)
</gnuplot>

Walsheve funkcije

Multiplot

Gnuplot Plot

Tabela

Gnuplot Plot

Gnuplot Plot

Gnuplot Plot

Gnuplot Plot

Trigonometrične funkcije

Gnuplot Plot

<gnuplot>
set size 0.5,0.5
plot [-10:10] sin(x),atan(x),cos(atan(x))
</gnuplot>

Gnuplot Plot

<gnuplot>
set size 0.5,0.5
plot [-0.1:6.5] sin(x),cos(x)
</gnuplot>

Statistika

Gnuplot Plot

<gnuplot>
set size 0.5,0.5
set style fill solid 1.000000 border -1
set samples 25, 25
set noxtics
set noytics
set title "Boxes with style\nfill solid border -1" 0.000000,0.000000  font ""
set yrange [ 0.00000 : 120.000 ] noreverse nowriteback
plot [-10:10] 100/(1.0+x*x) title 'distribution' with boxes
</gnuplot>

Gnuplot Plot

<gnuplot>
set size 0.5,0.5
set title "Normalna distribucija"
plot [-3:3][0:1] norm(x)
</gnuplot>

Gnuplot Plot

<gnuplot>
set size 0.5,0.5
set terminal png size 820,620 
set dummy u,v
set format x "%3.2f"
set format y "%3.2f"
set format z "%3.2f"
unset key
set parametric
set samples 50, 50
set style function dots
set title "Lattice test for random numbers" 0.000000,0.000000  font ""
set xlabel "rand(n) ->" 0.000000,0.000000  font ""
set xrange [ 0.00000 : 1.00000 ] noreverse nowriteback
set ylabel "rand(n + 1) ->" 0.000000,0.000000  font ""
set yrange [ 0.00000 : 1.00000 ] noreverse nowriteback
set zlabel "rand(n + 2) ->" 0.000000,0.000000  font ""
set zrange [ 0.00000 : 1.00000 ] noreverse nowriteback
splot rand(0), rand(0), rand(0)
</gnuplot>

Gnuplot Plot

<gnuplot>
set size 0.5,0.5
set format x "%2.0f"
set format y "%3.2f"
set key right top Right noreverse enhanced box linetype -1 linewidth 1.000 samplen 4 spacing 1 width 0 height 0 autotitles
set label 1 "mu" at 6, 0.0193014, 0 left norotate back nopoint
set label 2 "sigma" at 8.23607, 0.108213, 0 left norotate back nopoint
set arrow 1 from 5.5, 0, 0 to 5.5, 0.178412, 0  nohead back nofilled linetype 1 linewidth 1.000
set arrow 2 from 5.5, 0.108213, 0 to 7.73607, 0.108213, 0  nohead back nofilled linetype 1 linewidth 1.000
set samples 200, 200
set xtics border mirror norotate 0.00000,1,14.0000
set ytics border mirror norotate 0.00000,0.0193014,0.193014
set title "poisson PDF using normal approximation" 0.000000,0.000000  font ""
set xlabel "k, x ->" 0.000000,0.000000  font ""
set xrange [ -1.00000 : 15.0000 ] noreverse nowriteback
set ylabel "probability density ->" 0.000000,0.000000  font ""
set yrange [ 0.00000 : 0.193014 ] noreverse nowriteback
nexp(x)=lambda*exp(-lambda*x)
normal(x)=invsqrt2pi/sigma*exp(-0.5*((x-mu)/sigma)**2)
pareto(x)=x<a?0:b/x*(a/x)**b
poisson(x)=mu**int(x)/int(x)!*exp(-mu)
mu = 5.0
invsqrt2pi = 0.398942280401433
sigma = 2.23606797749979
plot poisson(x), normal(x - 0.5)
</gnuplot>

Gnuplot Plot

<gnuplot>
set size 0.5,0.5
set output 'daljica.png'
unset border
unset key
set terminal png transparent nocrop enhanced size 420,320
set label 1 "(x1,y1,z1)" at 1, 3, 0 left norotate back nopoint
set label 2 "(x2,y2,z2)" at 3, 15, 0 left norotate back nopoint
set noxtics
set noytics

plot '-' using 1:2 t '' with linesp lt 1 lw 3
 1 3
 4 16
 e
</gnuplot>

Energijski nivoji

Gnuplot Plot

 <gnuplot>
 set size 0.5,0.5
 n_i(x) = k*T*log(1/x-1) + E_F
 
 g_i = 1
 E_F=0
 T = 300
 epsilon_i = 0
 k = 0.00008617343
 plot [0:1][-0.2:0.2] n_i(x),E_F
 </gnuplot>
 

Bremenske karakteristike

MOSFET

Gnuplot Plot

Gnuplot Plot

Gnuplot Plot

Prevajalne karakteristike

Uporaba kompleksnih števil

Gnuplot Plot

A(jw) = ({0,1}*jw/({0,1}*jw+p1)) * (1/(1+{0,1}*jw/p2))
p1 = 10
p2 = 10000
set size 0.65,0.6
set dummy jw
set grid x y2
#set key default
unset key
set logscale xy
set log x2
unset log y2
set title "Amplitude and Phase Frequency Response"
set xlabel "jw (radians)"
set xrange [3 : 3e4]
set x2range [3 : 3e4]
set ylabel "magnitude of A(jw)"
set y2label "Phase of A(jw) (degrees)"
set ytics nomirror
set y2tics
set tics out
set autoscale  y
set autoscale y2
plot abs(A(jw)), 180/pi*arg(A(jw)) axes x2y2

Gnuplot Plot

set size 0.5,0.5
unset key
n0 = 1
n1 = -1
p0 = 0.95*{0,1}
p1 = -0.95*{0,1}
K0=40
 
H(Omega) = 10**(K0/20)*(1 - exp(-2*Omega*{0,1}))/(1 + (p0*p1) * exp(-2*Omega*{0,1}))
set dummy Omega
 
plot[0:pi] [-200:200] 20*log(abs(H(Omega)))
Osebna orodja
Imenski prostori
Različice
Dejanja
navigacija
orodja