【问题标题】:gnuplot multiplot equal height of each plotgnuplot multiplot 每个图的高度相等
【发布时间】:2020-09-11 15:28:03
【问题描述】:

我想制作一个 gnuplot 多图,其中三个图相互重叠。到目前为止,它一直有效,当我不添加 x 轴标签并将每个 tmargin 和 bmargin 设置为相等时。但是当我在最低图下添加 x 轴标签和 xtics 时,该图的高度会缩小 - 如图所示。你知道如何在最低图下制作带有 x 轴标签的大小相等的图吗?

这是我的代码:

reset

set lmargin 9
set rmargin 3
unset key

set xrange [-1:41]

set boxwidth 0.4
set style fill solid noborder

set multiplot layout 3,1

set xtics format ""
set xtics 5
unset xlabel
set ytics 100
set logscale y
set format y "10^{%L}"

set key ins vert right top
set tmargin 0.8
set bmargin 0.5
set yrange [1:100000000]
#set ylabel "Photonen / s  [Mio.]" offset 0,0,0 font ""
plot "300sLinienMit0.txt" u (($1)):($2/300) w boxes lc rgb "#6699ff" title "185,72 keV"

set xtics format ""
unset xlabel

set ytics 10
set tmargin 0.5
set bmargin 0.5
set yrange [1:1000]
set ylabel "Photonen [s^{-1}]" offset -2,0,0 font ""
plot "300sLinienMit0.txt" u ($1):($3/300) w boxes lc rgb "#ff6600" title "351,03 keV"
unset ylabel

set xtics format ""
unset xlabel

set tmargin 0.5
set yrange [1:1000]
set format x "%g"

set xtics 5 offset 0,0,0
set bmargin 3.5
set xlabel "Blei-Abschirmung [mm]" offset 0,0,0 font "" 
#set ylabel "Photonen / s  [Tsd.]" offset 0,0,0 font ""
plot "300sLinienMit0.txt" u ($1):($4/300) w boxes lc -1 title "831,98 keV"

unset multiplot

【问题讨论】:

    标签: plot gnuplot height equals


    【解决方案1】:

    您必须在多图环境中自己设置(子)图的位置和大小。 重要的是set bmargin 0。您通过set origin 0, myBottomMargin 设置的底部图的边距。然后相应地设置其他地块的原点和大小。我希望下面的代码是不言自明的。

    代码:

    ### multiplot with equal plot heights
    reset session
    
    myBottomMargin = 0.15
    myPlotHeight = (1. - myBottomMargin)/3
    
    set multiplot
    
        set xlabel "This is the xlabel for all plots"
        set ytics 0.5
        set grid xtics, ytics
        set origin 0, myBottomMargin
        set size 1, myPlotHeight
        set bmargin 0
        set label 1 at graph 1.0, graph 1.0 "185.72 keV" right offset -1,-1
        plot sin(x) w l lc 1 notitle
        
        unset xlabel
        set format x ""
        set origin 0, myBottomMargin+myPlotHeight
        set label 1 at graph 1.0, graph 1.0 "351.03 keV" right offset -1,-1
        plot sin(2*x) w l lc 2 notitle
        
        set origin 0, myBottomMargin+2*myPlotHeight
        set label 1 at graph 1.0, graph 1.0 "831.98 keV" right offset -1,-1
        plot sin(3*x) w l lc 3 notitle
    
    unset multiplot
    ### end of code
    

    结果:

    【讨论】:

    • 哇!完美的!非常感谢 :) 现在唯一的事情是,我不想要键中的符号,只是一个数字。有什么想法吗?
    • 感谢您的加入。通过这种方式,钥匙符号不可见,但数字例如“185,72”仍然和之前一样。右对齐会更漂亮,就像我上图中的符号一样。有谁知道如何删除键中的符号,以便情节的标题在右上角对齐?
    • 我在 gnuplot 5.2 手册(5.2 版由:Ethan A Merritt 和许多其他人组织)的第 62 页上找到了一个情节,其中密钥只有一个文本,没有符号,但没有显示的脚本 - 我仍然不知道该怎么做,但它可能!
    • 如果你只想在每个图的右上角有一个数字,你可以使用set label。检查help label。始终使用label 1 覆盖以前的标签。我将修改示例。
    • @pablobanano 这能回答你的问题吗?任何回应表示赞赏。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-04-19
    • 1970-01-01
    • 1970-01-01
    • 2019-06-04
    • 1970-01-01
    • 2019-11-28
    • 1970-01-01
    相关资源
    最近更新 更多