websealevel
websealevel

Reputation: 101

gnuplot: How to plot with variable linewidth?

I have some issues with a plot i would like to make.

Let say I have a data file with 5 columns like: x,y,x+dx,y+dy, a .

I would like to plot a vector field with a arrow thickness proportional to a, but I don't know how to do it. Suppose I scale a in a way that it belongs to [0:100], should I have to define a linetype for each interval [0:5],[5:10] etc... ? I have tried with column function, but it is not working.

c1=12

plot 'data' u 3:4:($5-$3):($6-$4) w vectors lw column(c1)

(Note: the a term is in the twelve column)

And i tried this command:

plot 'data' u 3:4:($5-$3):($6-$4):12 w vectors nohead arrowstyle variable

Upvotes: 1

Views: 1957

Answers (1)

Christoph
Christoph

Reputation: 48430

Your last approach with the variable arrow style should work fine. Consider the following example:

set samples 11
set xrange [0:100]
set for [i=1:101] style arrow i lw i/10.0 nohead
unset key
plot '+' using 1:1:(2):(10):($1+1) with vectors arrowstyle variable

Here I defined 100 arrow styles which differ only in their linewidth. The result with version 4.6.5 is

enter image description here

In your case it should be enough to use

set for [i=1:101] style arrow i lw i/10.0 nohead
plot 'data' u 3:4:($5-$3):($6-$4):12 w vectors nohead arrowstyle variable

Of course you must make sure, that column 12 is in the range [1:101]. You could also use stats to determine the limits of the values in column 12 and write a function map(x) which maps the values of this column to the required range [1:101].

Upvotes: 2

Related Questions