如何使用 gnuplot 内联颜色列?

How do you inline a color column with gnuplot?

考虑到 Gnuplot: Variable colors (and linewidths) for 2D-Vector plot 上已接受的答案,为什么这行不通?:

set xrange [0:10]
set yrange [0:10]
plot '-','-','-','-','-' with vectors lw 3 lc rgb variable
1
1
1
1 
e
1
2
3
4
e
2
2
2
2
e
0
0
0
0
e
0x000000
0xff0000
0xff0000
0xffff00
0x382288
e

错误:第 26 行:变量颜色的列不足

第26行是第一个颜色0x000000

您可能正在寻找以下内容:

### inline data
reset session

set xrange [0:10]
set yrange [0:10]
plot '-' u 1:2:3:4:5 with vectors lw 3 lc rgb variable
1  1  2  0  0x000000
1  2  2  0  0xff0000
1  3  2  0  0xff0000
1  4  2  0  0xffff00
2  5  2  0  0x382288
e
### end of code

就我个人而言,我更喜欢以下方式。它的优点是您可以在进一步的绘图中“重复使用”数据。而使用 '-' 您将不得不再次输入数据。检查 help special-filenames.

### inline data with datablock
reset session

$Data <<EOD
1  1  2  0  0x000000
1  2  2  0  0xff0000
1  3  2  0  0xff0000
1  4  2  0  0xffff00
2  5  2  0  0x382288
EOD

set xrange [0:10]
set yrange [0:10]
plot $Data u 1:2:3:4:5 with vectors lw 3 lc rgb variable
### end of code

结果:(对于两个版本)