質問

Here is my data file:

25 10 8
0  50 11
34 25 0
14 0 22
200 25 56

And I plot 3D vectors with splot:

splot "data" using (0):(0):(0):1:2:3 with vectors

enter image description here

But I would like different colors for my vectors, using something like ls nth_vector with splot (so ls 1 for the first line of the file, then ls 2, etc.). Is it possible?

Thanks!

役に立ちましたか?

解決

If you double space your data file you can achieve this using index. You can use awk within gnuplot to do the spacing on the fly:

splot for [i=0:system("wc -l < data")] '<awk -v s="\n" "{print s}1" data' using (0):(0):(0):1:2:3 index i notitle with vectors

The system command counts the number of lines in the file. awk prints two newlines for every line in the data file, so each line has a separate index. I have used a variable containing the \n character as this avoids difficulties in escaping strings.

edit

There's no need for any of that awk. You can use stats to get the number of lines in your file and every to plot each line separately:

stats 'data' nooutput
splot for [i=0:STATS_records] "data" using (0):(0):(0):1:2:3 every ::i::i with vectors notitle

image showing plot

他のヒント

You can use the row number (zeroth column) as linetype index for the linecolor variable option:

splot 'data' using (0):(0):(0):1:2:3:0 with vectors lc var

For the vectors plotting style you could even use arrowstyle variable to change the whole arrow settings.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top