将键放在gnuplot的多点图下方

将键放在gnuplot的多点图下方,gnuplot,Gnuplot,正如标题所示,我想把情节图例放在多点图下面。我只为其中一个绘图添加图例,因为所有绘图的线条样式都相同。我遇到的问题是,如果我通过将键添加到下面的set key,绘图本身的大小将调整为适合画布中的(大)键。我宁愿保持地块的大小。我尝试使用set key inside在multiplot中将该键添加为附加绘图,但如果该键太大,则该键可能与绘图重叠。我正在使用epslatex终端。没有更多详细信息,很难知道这是否有用,但gnuplot允许您以绝对值指定键的位置: set key at screen 0

正如标题所示,我想把情节图例放在多点图下面。我只为其中一个绘图添加图例,因为所有绘图的线条样式都相同。我遇到的问题是,如果我通过
将键添加到下面的set key
,绘图本身的大小将调整为适合画布中的(大)键。我宁愿保持地块的大小。我尝试使用
set key inside
在multiplot中将该键添加为附加绘图,但如果该键太大,则该键可能与绘图重叠。我正在使用epslatex终端。

没有更多详细信息,很难知道这是否有用,但gnuplot允许您以绝对值指定键的位置:

set key at screen 0.5,screen 0.1 #for example

这可能允许您将其移动到您想要的任何位置…

这里有一种方法,可以使用一些函数来帮助调整绘图页边距的位置:

#!/usr/bin/env gnuplot

### n: change this parameter to equal the number of data sets to be plotted
n = 3
# t: top margin in pixels
t = 75.0
# b: key height in pixels (bottom margin)
b = 300.0
# h: height of output in pixels
h = 150.0*n + t + b

### define functions to help set top/bottom margins
top(i,n,h,t,b) = 1.0 - (t+(h-t-b)*(i-1)/n)/h
bot(i,n,h,t,b) = 1.0 - (t+(h-t-b)*i/n)/h

### first set up some basic plot parameters
set term pngcairo enhanced size 800,h font 'FreeMono-Bold,14'
set output 'bigkey.png'

set title 'Big Key Plot'
set ylabel 'Y Axis'

set multiplot layout (n+1),1
### First plot
# change only plot command here
currentplot = 1
set tmargin at screen top(currentplot,n,h,t,b)
set bmargin at screen bot(currentplot,n,h,t,b)
unset key
unset xtics
plot sin(1*x) title 'Line 1', \
     sin(2*x) title 'Line 2', \
     sin(3*x) title 'Line 3', \
     sin(4*x) title 'Line 4', \
     sin(5*x) title 'Line 5', \
     sin(6*x) title 'Line 6', \
     sin(7*x) title 'Line 7'
### Middle plot
# copy and paste this code to make more middle plots
currentplot = currentplot + 1
set tmargin at screen top(currentplot,n,h,t,b)
set bmargin at screen bot(currentplot,n,h,t,b)
unset title
replot
### Last plot
# change only plot command here
currentplot = currentplot + 1
set tmargin at screen top(currentplot,n,h,t,b)
set bmargin at screen bot(currentplot,n,h,t,b)
set xlabel 'X Axis'
set xtics
replot
### Last (key) plot
set tmargin at screen bot(n,n,h,t,b)
set bmargin at screen 0
set key center center
set border 0
unset tics
unset xlabel
unset ylabel
set yrange [0:1]
plot 2 t 'Line 1', \
     2 t 'Line 2', \
     2 t 'Line 3', \
     2 t 'Line 4', \
     2 t 'Line 5', \
     2 t 'Line 6', \
     2 t 'Line 7'

unset multiplot
结果如下:

您必须手动调整的是绘图的数量和底部边距的大小,这是绘制关键帧的地方。评论通常会说你必须在哪里改变事情

我把钥匙单独放在一个绘图中,这样就可以很容易地保持其他绘图的大小完全相同。当y范围为0到1时,绘制数字2可防止线显示在关键点图中


这主要是基于我的回答,这就是为什么我的情节都很感人。如果希望在绘图之间留出间隙,可以使用附加的margin参数调整top()和bot()函数。

创建一个我们可以使用的最小脚本可能会有所帮助——例如,在绘图数据文件时,只需输入绘图命令plotting
sin(x)
cos(x)
这样我们就可以调整布局以使其正确。是的,谢谢。我尝试了这个蝙蝠,因为它打印了一个包含多列的键,而不是一列,即使我在屏幕0.5上使用
set键,屏幕0.1左反向间距1.5 samplen 2.5 maxcols 1 maxrows 10
也许这种行为是因为图例(带有长文本)实际上比绘图本身大。但这正是我想把它放在外面的原因。是的,这个情节看起来很像我的。只有我使用的是带有
set multiplot layout 5,1 columnsfirst
的自动布局。对于这种情况是否有明显的修改,或者这是您不使用自动布局的原因。我还将图例作为一个单独的绘图,并尝试更改最后一个绘图的底部边距,但似乎没有效果…如果能够使用
多点布局设置将很好,但据我所知,它将所有绘图限制为相同大小。在您的例子中,关键点绘图更大,因此定义这些函数使所有绘图大小相同,但控制顶部和底部空间是很有帮助的。有一件事我需要澄清:为什么我提到的“底部利润”实际上是从所有地块下方的角度来看的利润;从gnuplot的角度看,这不是边际。gnuplot页边距在绘图区域本身内。我使用
epsletse
终端尝试了您的脚本,我认为即使关键点大得多(标签更长),它也可以进行一些调整。下面的
set key
现在不起作用,这一事实在我看来是一个bug。我想知道底部的图例是水平排列还是垂直排列。水平排列有助于将另一个图形绘制为第四个图形。知道应该更改代码的哪一部分,以便图例显示水平排列,这将非常有帮助。