How to create a flow line like arrow lines in Gnuplot?

I want to create a streamline as arrow lines in Gnuplot, I already have the data I need, so I think that my problem is not the same as this post says and differs from this message , because I already received the data needed for stromal lines .

I did like this:

done

Thus, the red lines are vectors showing the flow field, and the green line are the flow lines to direct readers in the flow direction. And all the big blue arrows are my goal of being put on GNUPLOT. I know how to draw the middle arrows, as this post showed, but what code do I need if I want to draw more arrows along the lines?

To be more detailed, how can I build a drawing like this:

aim

I provide the data file here:

speed.txt for vector stream field data as "index, X, Y, vx, vy, particle number"

line.txt for simplified data like "X, Y"

and the gnu file is bleow:

set terminal postscript eps size 108,16 enhanced font "Arial-Bold,100"
set output 'vector.eps'

unset key
set tics
set colorbox
set border 0
set xtics 2
#set xlabel 'x'
#set ylabel 'y'


set xrange [0:108]
set yrange [0:16]
#set cbrange [0:40]

set nolabel
set style line 4 lt 2 lc rgb "green" lw 2

plot 'velcoity.txt' u 2:3:(250*$4):(250*$5) with vectors lc 1,'line.txt' u 1:2 ls 4

Thanks!

+4
source share
1 answer

To draw arrows along the line, you can use the build style again vectors, as with the flow field.

But in order to get the right plot, you have to consider a few points:

  • gnuplot . , , . , size ... fixed, 5.0

  • , x y . , ( ).

  • using. :

    if rownumber modulo 10 == 0:
        save x and y values
    else if rownumber modulo 10 == 1:
        draw arrow from previous point to current point, only with a head
    else 
        ignore the point.
    

    using :

    ev = 10
    avg = 1
    sc = 0.1
    plot 'line.txt' u (prev_x = (int($0)%ev == 0 ? $1 : prev_x), prev_y = (int($0)%ev == 0 ? $2 : prev_y), int($0)%ev == avg ? $1 : 1/0):2:(sc*(prev_x-$1)):(sc*(prev_y-$2)) w vectors backhead size 2,20,90 fixed ls 4
    

    , : ev , avg , , sc .

. script

reset
unset key
set tics
set colorbox
set border 0
set xtics 2

set autoscale xfix
set autoscale yfix
set autoscale cbfix
set style line 4 lt 2 lc rgb "green" lw 2
ev=30
avg=3
sc=0.1
field_scale=500
plot 'velcoity.txt' u 2:3:(field_scale*$4):(field_scale*$5):(sqrt($4**2+$5**2)) with vectors size 1,15,45 noborder lc palette,\
     'line.txt' u 1:2 ls 4 w l,\
     '' u (prev_x = (int($0)%ev == 0 ? $1 : prev_x), prev_y = (int($0)%ev == 0 ? $2 : prev_y), int($0)%ev == avg ? $1 : 1/0):2:(sc*(prev_x-$1)):(sc*(prev_y-$2)) w vectors backhead size 2,20,90 fixed ls 4

(qt terminal):

enter image description here

+3

Source: https://habr.com/ru/post/1612459/


All Articles