1
votes

I have already asked about vector fields in here. Now I want to know a bit more about it.

How can I make it so that each arrow has the same fixed length and define the magnitude of the value by color?

And is it still not possible to plot streamlines in gnuplot? If possible, how can I do that?

For now I have this and need to upgrade it.

set term pngcairo
set title 'Navier-Stokes Equation'
set terminal png size 1280,720
set output 'vec.png'
plot 'vec' u 1:2:($3/$5):($4/$5) w vec t 'Vector Field'

enter image description here

UPDATE

Thanks to @theozh I've got what I wanted. I want to share my result as it could be useful for someone else. Now I use these instructions to plot my vector field.

reset session
set size square
set palette rgb 33, 15, 10
set term pngcairo
set title 'Navier-Stokes Equation'
set terminal png size 1280, 720
set output 'vec.png'
plot 'vec.dat' u 1:2:(0.08*$3):(0.08*$4):(sqrt($3**2+$4**2)) w vec lw 2 lc palette notitle

enter image description here

1
For streamlines you need an ODE integrator. gnuplot has advanced from pocket calculator capabilities to some programming structures, but not to the level of a numerics system like matlab (which in turn incorporated limited CAS capabilities, while the Mathematica CAS incorporated comprehensive numerics capabilities). I do not think that the makers of gnuplot strive to re-invent the likes of octave, mupad etc.Lutz Lehmann
glad that I could help. Well, you haven't normalized your arrows. On purpose? The magnitude is already shown by the color, so no need to additionally show it by the length of the arrow. In your case the normalization would be Scaling=0.08 and ...(Scaling*$3/sqrt($3**2+$4**2)):(Scaling*$4/sqrt($3**2+$4**2)):(sqrt($3**2+$4**2))....theozh
@theozh thanks again. it will be a good additionmend4x

1 Answers

2
votes

About the same length: simply normalize your vectors.

About the color: you can add a "column" and the end. The last column will define the color according to a palette.

I don't know about streamlines (what exactly they are and how to possibly realize them).

With the example code:

### plot with vectors
reset session
set size square

set samples 25
set palette rgb 33,13,10

Scaling = 0.5
plot [-5:5] '++' u 1:2:\
    (Scaling*$1/sqrt($1**2+$2**2)):(Scaling*$2/sqrt($1**2+$2**2)): \
    (sqrt($1**2+$2**2)) with vectors lc palette notitle
### end of code

You'll get:

enter image description here