将关键字放在gnuplot中的多时隙图下方

hig*_*guy 2 gnuplot

正如标题所示,我想将情节图例放在多图表下方.我为其中一个图添加了图例,因为所有线条样式都相同.我遇到的问题是,如果我添加键set key below,则绘图本身会调整大小以适应画布中的(大)键.我宁愿保持情节的大小.我尝试在多重绘图中添加密钥作为附加图set key inside,但是如果密钥太大,则密钥可以与图重叠.我正在使用epslatex终端.

mgi*_*son 7

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

set key at screen 0.5,screen 0.1 #for example
Run Code Online (Sandbox Code Playgroud)

这可能会让你把它移动到你想要的任何地方......


and*_*ras 7

这是一种使用某些函数来帮助调整图中边距位置的方法:

#!/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
Run Code Online (Sandbox Code Playgroud)

结果如下: 在此输入图像描述

您需要手动调整的事项是绘图的数量和底部边距的大小,这是绘制密钥的位置.评论一般说明你必须改变的地方.

我把钥匙单独放在一个图中,以便容易保持其他图的大小完全相同.当y范围为0到1时绘制数字2会使得线条不会显示在关键图中.

这主要是基于我在这里的答案,这就是为什么我的情节都很感人.如果您希望绘图之间存在间隙,则可以使用额外的边距参数调整top()和bot()函数.