水平键在GNUPLOT中以垂直方式显示

时间:2018-05-16 10:44:11

标签: gnuplot

gnuplot中,我使用了水平键,但它在输出屏幕上显示我是垂直的。我尝试了所有替代方案,但发现很难做到这一点。

set terminal wxt size 600,600 enhanced font 'times new roman,10' persist
set xlabel "X-Axis"
set ylabel "Y-Axis"
set multiplot layout 2,3
set key box
set key horiz
set key at screen 0.5, 0.40
set title "1st"
set xrange [0:20]
plot    tan((pi/180)*x)   title "Analytical"   w l  ls 1,\
        tan(2*(pi/180)*x) title "Observed"     w lp ls 2,\
        tan(3*(pi/180)*x) title "Experimental" w lp ls 3

set title "2nd"
set xrange [0:20]
plot    tan((pi/180)*x)   title "Analytical"   w l  ls 1,\
        tan(2*(pi/180)*x) title "Observed"     w lp ls 2,\
        tan(3*(pi/180)*x) title "Experimental" w lp ls 3

set title "3rd"
set xrange [0:20]
plot    tan((pi/180)*x)   title "Analytical"   w l  ls 1,\
        tan(2*(pi/180)*x) title "Observed"     w lp ls 2,\
        tan(3*(pi/180)*x) title "Experimental" w lp ls 3

unset multiplot

还有其他选择吗?点击下面的输出看情节:

enter image description here

2 个答案:

答案 0 :(得分:1)

您可以通过指定set key vertical maxrows 1

强制图例由单行组成
set xlabel "X-Axis"
set ylabel "Y-Axis"
set multiplot layout 2,3
set key at screen 0.5, 0.40 center vertical height 1 box maxrows 1
set title "1st"
set xrange [0:20]
plot    tan((pi/180)*x)   title "Analytical"   w l  ls 1,\
    tan(2*(pi/180)*x) title "Observed"     w lp ls 2,\
    tan(3*(pi/180)*x) title "Experimental" w lp ls 3

set title "2nd"
set xrange [0:20]
plot    tan((pi/180)*x)   title "Analytical"   w l  ls 1,\
    tan(2*(pi/180)*x) title "Observed"     w lp ls 2,\
    tan(3*(pi/180)*x) title "Experimental" w lp ls 3

set title "3rd"
set xrange [0:20]
plot    tan((pi/180)*x)   title "Analytical"   w l  ls 1,\
    tan(2*(pi/180)*x) title "Observed"     w lp ls 2,\
    tan(3*(pi/180)*x) title "Experimental" w lp ls 3

unset multiplot

enter image description here

答案 1 :(得分:0)

您的3个图中的每一个都会生成一个单独的密钥。多色布局将所有3个图放在同一页上,但每个图仍然只是页面宽度的1/3,并设置其键的最大水平尺寸。在示例中,您将每个键重新放置在页面底部的相同位置,以便它们完全位于彼此的顶部。这不会改变它们的大小或形状,只会改变它们的位置。

您可以做的是手动将每个标题放在页面上,而不参考自动生成的密钥。为了为手动放置的键条目留出空间,您可以给出明确的多时隙布局边距。

set multiplot layout 1,3 margins .1, .9, .3, .9
set key
plot    tan((pi/180)*x)   title "Analytical"   at screen .25,.1 w l  ls 1,\
        tan(2*(pi/180)*x) title "Observed"     at screen .50,.1 w lp ls 2 ,\
        tan(3*(pi/180)*x) title "Experimental" at screen .75,.1 w lp ls 3
unset key
plot ...
plot ...
unset multiplot

在手动定位的标题周围放置一个框是一个单独的问题。