Gnuplot:为colorbox添加无穷大值

时间:2018-03-15 14:05:01

标签: gnuplot

我想用Gnuplot绘制一个简单的热图,这与这个例子非常相似:

unset key
set cbrange [0:6]
set xrange [0:10]
set yrange [0:5]
set size ratio -1
set cbtics out nomirror
set palette maxcolors 12 model RGB defined (0 '#1a9641', 1 '#a6d96a', 2 '#ffffbf', 3 '#fdae61', 4 '#d7191c')
$map1 << EOD
5.5 4.0 3.5 1.0 0.5 5.0 4.5 3.0 1.5 0.0
2.0 2.5 0.0 inf inf 4.5 3.0 0.5 0.0 1.5
0.5 0.0 0.5 inf inf 0.0 0.5 0.0 1.5 0.0
0.0 0.5 0.0 2.5 3.0 0.5 0.0 0.5 2.0 3.5
0.5 1.0 2.5 4.0 3.5 2.0 2.5 0.0 0.5 1.0
EOD
plot '$map1' using ($1+.5):($2+.5):($3) matrix with image

这是相应的情节enter image description here

如您所见,矩阵包含无穷大值。我想在彩色盒中添加一个额外的颜色(例如蓝色),特别是对于无穷大值(中间的大红色正方形应该显示为蓝色)。

起初我以为我只需要在我定义的颜色框颜色值的末尾再添加一种颜色。但这会导致最后两种颜色(红色和蓝色)之间的颜色过渡,因为蓝色将是cbrange最大值的相关颜色。但非无穷大值的最大值应保持为6和红色。

结果看起来应该是这样的enter image description here

有任何想法吗?

1 个答案:

答案 0 :(得分:3)

您将需要类似以下三行的内容,根据您所需的渐变手动填充颜色0-11(我曾使用this site生成过去的渐变。)

set cbrange [0:6.5]
set palette maxcolors 13 model RGB defined \
( 0 '#222222', 1 '#333333',   2 '#444444', \
  3 '#555555', 4 '#666666',   5 '#777777', \
  6 '#888888', 7 '#999999',   8 '#aaaaaa', \
  9 '#bbbbbb', 10 '#cccccc', 11 '#dddddd', 12 '#dd0000')
set cbtics ("0" 0, "1" 1, "2" 2, "3" 3, "4" 4, "5" 5, "6" 6, "inf" 6.5)

相关问题