在gnuplot中使用框时颜色重复 [英] Color repetition when using boxes in gnuplot

查看:55
本文介绍了在gnuplot中使用框时颜色重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据文件只有两列,这些列上的以下MWE产生具有重复颜色的框.是否可以为每个盒子产生独特的颜色?

My data file has just two columns.The following MWE on those columns produces boxes with repeated colors. Is it possible to produce unique colors for each box?

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 ($0):2:($0):xticlabels(1) \
                                          notitle w boxes lc variable 
quit

这是我得到的输出:

推荐答案

经过SO专家的几次尝试和帮助,我提出了以下解决方案:不过,没有一个是完美的.

After few attempts and help from the SO experts, I came up with the following solutions; none of them perfect, though.

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

Solution 1: ( with a random repetition using rand and rgb calls)

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 ($0):2:($0):xticlabels(1) \
                                          notitle w boxes lc variable 
quit

以下是相应的输出:

使用调色板定义(解决方案2):

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 ($0):2:($0):xticlabels(1) \
                                          notitle w boxes lc palette 
quit

这是输出:

对于其他解决方案(解决方案3 ),请用以下几行替换上面的定义:

For another solution (solution 3), replace the definition above with the following lines:

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

这就是我得到的:

这篇关于在gnuplot中使用框时颜色重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆