gpt4 book ai didi

gnuplot - 水平颜色框对面的 cbtics 标签

转载 作者:行者123 更新时间:2023-12-03 15:01:14 26 4
gpt4 key购买 nike

假设我有以下脚本来制作一种轮廓图。

set colorbox horizontal user origin 0.1, 0.9 size 0.8, 0.05
set pm3d map
splot x*y

这给出了以下结果。

Sample image

现在,我想要实现的是,刻度标签会自动结束在颜色框的相对位置。我怎样才能做到这一点?

我试过:
  • set cbtics mirror ,但这不会改变任何事情。
  • 我试过 set cbtics offset 0,3 .这原则上有效,但我每次都必须调整它。

  • 我的 gnuplot版本是 4.6.2

    最佳答案

    这是使用 multiplot 的一种繁琐的解决方法.
    这有点冗长,但至少应该消除在更改 Canvas 大小时为了找到正确的 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
    结果: (使用 gnuplot 4.6.0 生成)
    enter image description here

    关于gnuplot - 水平颜色框对面的 cbtics 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24907570/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com