감동, 마음이 움직이는 것

[gnuplot] vector field그리기 본문

Tips (Utility, Computer Language, and etc.)

[gnuplot] vector field그리기

Struggler J. 2017. 1. 27. 22:57

http://www.gnuplotting.org/vector-field-from-data-file/

http://www.gnuplotting.org/vector-field-from-function/


set samples 17    # x-axis
set isosamples 15 # y-axis
plot '++' u ($1-dx($1,$2)/2.0):($2-dy($1,$2)/2.0):\
    (dx($1,$2)):(dy($1,$2)):(v($1,$2)) \
    with vectors head size 0.08,20,60 filled lc palette

I tried to draw vector field from the functions.

Below is my gnuplot script and result.


#vector: direction and norm

fx(x, y) = x*(1.-x-y)

fy(x, y) = y*(1.-x-y)

vnorm(x, y)=sqrt(fx(x,y)**2 + fy(x,y)**2)


#vector functions

dx(x,y) = scaling*fx(x,y)/vnorm(x,y)

dy(x,y) = scaling*fy(x,y)/vnorm(x,y)


#source papameters

scaling = 10


set xr[0:100]

set yr[0:100]

set palette defined (3 '#fff4c2', 6 '#f0a848',  9 '#784860')

set samples 10

set isosamples 10

plot '++' u ($1-dx($1,$2)/2.0):($2-dy($1,$2)/2.0):(dx($1,$2)):(dy($1,$2)):(vnorm($1,$2)) with vectors head size 0.08,20,60 filled lc palette lw 7 t ''