假设我有以下脚本来制作一种轮廓图。
set colorbox horizontal user origin 0.1, 0.9 size 0.8, 0.05
set pm3d map
splot x*y
Run Code Online (Sandbox Code Playgroud)
这给出了以下结果。

现在,我想要实现的是,刻度标签会自动结束在颜色框的相反位置。我怎样才能做到这一点?
我试过:
set cbtics mirror,但这不会改变任何事情。set cbtics offset 0,3。这原则上有效,但我每次都必须调整它。我的gnuplot版本是4.6.2
这是一种使用multiplot. 它有点长,但至少应该消除在更改画布大小时为了找到正确的 cbtics 标签偏移而进行的摆弄。它适用于 gnuplot 4.6(OP 问题的时间)。对于当前的 gnuplot 版本,它可能看起来略有不同,但可以使用参数进行调整CBHeight, CBWidth, CBPosX, CBPosY。
可能的改进:我还没有找到如何自动制作颜色框,例如与图表宽度相同并使用变量将其居中到图表GPVAL_...。
代码:
### horizontal color bar with xtics on top
reset
set multiplot
# actual plot
unset colorbox
set size square
set pm3d map
set isosamples 100
set samples 100
splot sin(1.3*x)*cos(.9*y)+cos(.8*x)*sin(1.9*y)+cos(y*.2*x) notitle
# horizontal "pseudo" colorbar with tic labels on top
# size of colorbox in screen coordinates
CBHeight = 0.04
CBWidth = 0.49
CBPosX = (1 - CBWidth)/2 # centered
CBPosY = 0.87
set origin CBPosX,CBPosY
set size nosquare CBWidth,CBHeight
set lmargin 0; set tmargin 0; set rmargin 0; set bmargin 0
unset pm3d
unset tics
unset key
set x2tics out nomirror scale 1.0,0 offset 0,0
set colorbox horizontal user origin graph 0, graph 0 size graph 1, graph 1
set xrange [GPVAL_CB_MIN:GPVAL_CB_MAX]
plot x palette # dummy plot
unset multiplot
### end of code
Run Code Online (Sandbox Code Playgroud)
结果:(使用 gnuplot 4.6.0 生成)