如何为 gnuplot 箱形图使用调色板索引?

How to use color palette indexes for gnuplot box charts?

我尝试将一些索引映射到已定义调色板的颜色。但是定义的调色板似乎没有被使用。

给定一个文件 data.txt:

11
22
33
44

gnuplot 命令:

set nokey
set grid
set style fill solid
set boxwidth 0.5
set yrange [0:]
set palette model RGB maxcolors 7
set palette defined (0 'dark-violet', 1 'skyblue', 2 'dark-yellow', 3 'dark-green', 4 'dark-red', 5 'coral', 6 'green', 7 'purple')
plot 'data.txt' using 0:1:(column(0)+1) with boxes linecolor variable

这给出:

这与定义的调色板不匹配。我怎样才能让 gnuplot 在此处使用定义的调色板以及索引和颜色名称?

这是我想出的解决方案:

set nokey
set grid
set style fill solid
set yrange [0:]
set palette defined (0 'dark-violet', 1 'skyblue', 2 'dark-yellow', 3 'dark-green', 4 'dark-red', 5 'coral', 6 'green', 7 'purple')
set cbrange [0 : 7]
unset colorbox
plot 'data.txt' using 0:1:(0.5):(column(0)) with boxes linecolor palette

解决方案是在绘图行中添加方框宽度 (0.5) 并使用 cbrangelinecolor palette: