首页 > 解决方案 > 如何为 gnuplot 箱形图使用调色板索引?

问题描述

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

给定一个文件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 箱形图

这与定义的调色板不匹配。如何让 gnuplot 使用此处定义的调色板以及索引和颜色名称?

标签: 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)并使用cbrangeand linecolor palette

gnuplot 彩色框


推荐阅读