在 gnuplot 中使用框时的颜色重复

Color repetition when using boxes in gnuplot

我的数据文件只有两个 columns.The 跟随在这些列上的 MWE 生成具有重复颜色的框。是否可以为每个盒子制作独特的颜色?

reset
set term postscript eps size 5.5,4.5 enhanced color solid lw 2\
font "arial,28"
set key right
set xtics rotate -45 font ",20"
set style fill solid 1 border -1
plot 'rankdefcount.dat' using ([=10=]):2:([=10=]):xticlabels(1) \
                                          notitle w boxes lc variable 
quit

这是我得到的输出:

您可以尝试重新定义与要显示的框一样多的线型。代码应该在情节之前。

colors="black red orange #fa8072 ...." #[as much colors as needed] 
do for [L=1:words(colors)]{
set linetype L lc rgb word(colors,L)  
}

您可以在此处找到 gnuplot 的颜色。

http://www.uni-hamburg.de/Wiss/FB/15/Sustainability/schneider/gnuplot/colors.htm

经过几次尝试和 SO 专家的帮助,我想出了以下解决方案;不过,none 其中完美。

解决方案 1:(使用 rand 和 rgb 调用随机重复

reset
set term postscript eps size 5.5,4.5 enhanced color solid lw 2 font \
"arial,28"
set key right
rgb(r,g,b)=int(255*r)*65536+int(255*g)*256+int(255*b)
do for [i=1:31] {
   myrand=rand(int(rand(0)*i*100)+i*100)
   set style line i linecolor rgb rgb(rand(0),rand(0),rand(0))
}
set xtics rotate -45 font ",20"
set style fill solid 1 border -1
plot 'rankdefcount.dat' using ([=10=]):2:([=10=]):xticlabels(1) \
                                          notitle w boxes lc variable 
quit

这里是相应的输出:

使用调色板定义(方案二):

reset
set term postscript eps size 5.5,4.5 enhanced color solid lw 2 font \
"arial,28"
set key right
set palette color model HSV
set palette defined (0 0 1 1,1 1 1 1)
set palette defined ( 0 0 1 0, 1 0 1 1, 6 0.8333 1 1, 7 0.8333 0 1)
set boxwidth 0.5
unset colorbox
set xtics rotate -45 font ",20"
set style fill solid 1 border -1
plot 'rankdefcount.dat' using ([=11=]):2:([=11=]):xticlabels(1) \
                                          notitle w boxes lc palette 
quit

这是输出:

对于另一个解决方案(解决方案 3),将上面的定义替换为以下行:

set palette color model HSV
set pm3d explicit at b
set palette rgbformulae 3, 2, 2

这是我得到的: