Reputation: 33
I'm new in gnuplot and my aim is to plot arrows between each data coordinate. My ".dat" file has only two columns, separated by a single tab, where the first is the X and the second is the Y component. The head should be set in the next coordinate.
582.761 -326.288
574.806 -327.915
My command was:
plot 'file.dat' using 1:2 with vectors head filled
I only can obtain the following error message:
Not enough columns for this style
Sorry for the dumb question, but I couldn't understand neither the documentation nor other questions in the same subject.
Upvotes: 2
Views: 170
Reputation: 25734
If you check help vectors
you will see that with vectors
plotting style requires 4 values.
And if I understand your question correctly I guess you want to plot arrows from one data line to the next data line, correct?
By the expression (x0=x1,x1=$1,x0)
you keep the previous x
value in x0
and the current value in x1
, but you're plotting x0
. Same for y0
and y1
. And (x1-x0)
and (y1-y0)
are simply the delta x
and delta y
values which you need for the with vectors
plotting style.
Code:
### vectors from data line to the next
reset session
$Data <<EOD
1 1
2 2
3 5
2 4
1 2
EOD
x1=y1=NaN
plot $Data u (x0=x1,x1=$1,x0):(y0=y1,y1=$2,y0):(x1-x0):(y1-y0) w vectors head filled notitle
### end of code
Result:
Upvotes: 3