gnuplot colorbox 标签位置

问题描述

我将视图地图功能与通常为整数的数据集一起使用。当范围很小时,我会根据整个值的范围来限制颜色的数量。我正在寻找一个选项,将值标签放置在每个颜色框颜色范围的中心。例如,我希望“500”出现在黄色的中心而不是顶部,我希望“498”出现在黑色的中心而不是底部

解决方法

# colorbox centered at screen x=0.9,0.1 < screen y < 0.9
# known range [0:10] allows us to calculate tic positions
# 
set colorbox user origin screen 0.85,0.1 size 0.1,0.8
set cbrange [0:10]

# custom tic labels for the colorbox
unset cbtics
set style textbox opaque border lc "black" margins 0,0

do for [i = 1:9] {
    set label i at screen 0.9,(0.1 + 0.08*i)
    set label i sprintf("%03d",i) center boxed front
}

# some function for which the cbrange makes sense
set palette cubehelix 
set sample 101; set isosample 101; set xyplane 0
f(x,y) = 10*sinc(sqrt(x*x + y*y))

splot f(x,y) with pm3d

enter image description here