首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >在gnuplot中将键放在多图图形下

在gnuplot中将键放在多图图形下
EN

Stack Overflow用户
提问于 2013-02-06 00:30:53
回答 2查看 16.8K关注 0票数 3

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

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-02-07 01:40:54

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

代码语言:javascript
代码运行次数:0
运行
复制
#!/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可以避免在关键图中显示线条。

这主要是基于我的答案here,这就是为什么我有所有感人的情节。如果要在绘图之间留出间隙,可以使用附加的边距参数调整top()和bot()函数。

票数 8
EN

Stack Overflow用户

发布于 2013-02-06 02:10:49

如果没有更多细节,很难知道这是否有帮助,但gnuplot允许您以绝对值指定键的位置:

代码语言:javascript
代码运行次数:0
运行
复制
set key at screen 0.5,screen 0.1 #for example

这样你就可以把它移动到你想要的任何地方...

票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14712251

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档