Gnuplot 使用多点的唯一键和相同大小的图

Gnuplot 使用多点的唯一键和相同大小的图,gnuplot,Gnuplot,我想把这两个图放在一起,我只想用一个键。如果我用notitle设置一个,我可以用唯一的键得到它们,但是图形的形状会改变 set term postscript eps set output "temp.eps" set multiplot layout 1,2 set xtics ("32" 0, "128" 2, "512" 4, "2048" 6, "8192" 8) #set grid ytics set xrange [0:8] set yrange [0:100] p "8"

我想把这两个图放在一起,我只想用一个键。如果我用notitle设置一个,我可以用唯一的键得到它们,但是图形的形状会改变

set term postscript eps
set output "temp.eps"

set multiplot layout 1,2

set xtics ("32" 0, "128" 2, "512" 4, "2048" 6, "8192" 8)
#set grid ytics
set xrange [0:8]
set yrange [0:100]


p "8" u ($0):($6) w lp ps 0.75 notitle, "10" u ($0):($6) w lp lc rgb "#228B22" ps 0.75 notitle, "12"  u ($0):($6)w lp  lc rgb "black" ps 0.75 notitle , "14" u ($0):($6)w lp lc rgb "blue" ps 0.75 notitle, "16" u ($0):($6) w lp  lc rgb "#D2691E" ps 0.75 notitle, "18" u ($0):($6)w lp  lc rgb "#8A2BE2" ps 0.75 notitle, "20" u ($0):($6) w lp lc rgb "#20B2AA" ps 0.75 notitle 


set xtics ("32" 0, "128" 2, "512" 4, "2048" 6, "8192" 8)

#set grid ytics
set xrange [0:8]
set yrange [0:100]
set xlabel "nel"

#set key location
set key invert
set key reverse
set key center right
set key outside

p "8" u ($0):($6) w lp ps 0.75 title "8", "10" u ($0):($6) w lp lc rgb "#228B22" ps 0.75 title "10", "12"  u ($0):($6)w lp  lc rgb "black" ps 0.75 title "12", "14" u ($0):($6)w lp lc rgb "blue" ps 0.75 title "14", "16" u ($0):($6) w lp  lc rgb "#D2691E" ps 0.75 title "16", "18" u ($0):($6)w lp  lc rgb "#8A2BE2" ps 0.75 title "18", "20" u ($0):($6) w lp lc rgb "#20B2AA" ps 0.75 title "20"

 unset multiplot
这将产生如下结果:


可以看出,一个图形的形状会因其右侧的图例而改变。我正在寻找一种只使用图例的方法,并且使用左边图形的形状来使用两个图形

注意,我刚刚提供了示例代码。您可能需要更改它以获得正确的绘图

您可以使用以下示例在multiplot中设置各个绘图的大小:这是一个示例,您可能需要使用它才能获得正确的绘图大小

set size 0.8,1.2
尝试为每个单独的绘图设置它

您可以通过以下方式设置总体大小:

set terminal postscript enhanced eps 24 color size 10cm,15cm

注意,我刚刚提供了示例代码。您可能需要更改它以获得正确的绘图

您可以使用以下示例在multiplot中设置各个绘图的大小:这是一个示例,您可能需要使用它才能获得正确的绘图大小

set size 0.8,1.2
尝试为每个单独的绘图设置它

您可以通过以下方式设置总体大小:

set terminal postscript enhanced eps 24 color size 10cm,15cm

这个问题分为两部分,我会分别回答

1我可以对多个绘图使用同一个键吗

否,除非两个图中的数据的键恰好相同。例如,两个具有两行的绘图,其中两行在两个绘图中具有标题“一”和“二”,可以共享同一个键;在单独的绘图中,标题为“一”和“二”的两个绘图各有一行,不能共享同一个键

2当我有一把钥匙时,如何使我的多点天线大小相同

要做到这一点,没有简单的方法,要么手动调整绘图的大小,要么像中那样设置函数

在您的情况下,它可能看起来像:

#!/usr/bin/env gnuplot

### n: change this parameter to equal the number of data sets to be plotted
n = 2
# l: left margin in pixels
l = 75.0
# k: key height in pixels (right margin)
k = 150.0
# m: margin between plots
m = 40.0
# p: plot width
p = 300.0
# w: width of output in pixels
w = p*n + m*(n-1) + l + k

### functions to help set top/bottom margins
lft(i,n,w,l,k) = (l+(w-l-k)*(i-1)/n)/w
rgt(i,n,w,l,k) = (l+(w-l-k)*i/n - m)/w

### first set up some basic plot parameters
set term pngcairo enhanced size w,600
set output 'multikey.png'

set ylabel 'Y Axis'
set xlabel 'X Axis'

set multiplot layout 1,(n+1) title 'Main title'

### First plot
# change only plot command here
currentplot = 1
set lmargin at screen lft(currentplot,n,w,l,k)
set rmargin at screen rgt(currentplot,n,w,l,k)
unset key
plot sin(1*x) notitle, \
     sin(2*x) notitle
unset ylabel

### Middle data plot (commented out for this example)
# copy and paste this code to make more middle plots
#currentplot = currentplot + 1
#set lmargin at screen lft(currentplot,n,w,l,k)
#set rmargin at screen rgt(currentplot,n,w,l,k)
#unset title
#replot

### Last data plot
# change only plot command here
currentplot = currentplot + 1
set lmargin at screen lft(currentplot,n,w,l,k)
set rmargin at screen rgt(currentplot,n,w,l,k)
set xtics
replot

### Key plot
set lmargin at screen rgt(n,n,w,l,k)
set rmargin at screen 1
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'

unset multiplot
结果如下所示:

这个问题有两个部分,我将分别讨论

1我可以对多个绘图使用同一个键吗

否,除非两个图中的数据的键恰好相同。例如,两个具有两行的绘图,其中两行在两个绘图中具有标题“一”和“二”,可以共享同一个键;在单独的绘图中,标题为“一”和“二”的两个绘图各有一行,不能共享同一个键

2当我有一把钥匙时,如何使我的多点天线大小相同

要做到这一点,没有简单的方法,要么手动调整绘图的大小,要么像中那样设置函数

在您的情况下,它可能看起来像:

#!/usr/bin/env gnuplot

### n: change this parameter to equal the number of data sets to be plotted
n = 2
# l: left margin in pixels
l = 75.0
# k: key height in pixels (right margin)
k = 150.0
# m: margin between plots
m = 40.0
# p: plot width
p = 300.0
# w: width of output in pixels
w = p*n + m*(n-1) + l + k

### functions to help set top/bottom margins
lft(i,n,w,l,k) = (l+(w-l-k)*(i-1)/n)/w
rgt(i,n,w,l,k) = (l+(w-l-k)*i/n - m)/w

### first set up some basic plot parameters
set term pngcairo enhanced size w,600
set output 'multikey.png'

set ylabel 'Y Axis'
set xlabel 'X Axis'

set multiplot layout 1,(n+1) title 'Main title'

### First plot
# change only plot command here
currentplot = 1
set lmargin at screen lft(currentplot,n,w,l,k)
set rmargin at screen rgt(currentplot,n,w,l,k)
unset key
plot sin(1*x) notitle, \
     sin(2*x) notitle
unset ylabel

### Middle data plot (commented out for this example)
# copy and paste this code to make more middle plots
#currentplot = currentplot + 1
#set lmargin at screen lft(currentplot,n,w,l,k)
#set rmargin at screen rgt(currentplot,n,w,l,k)
#unset title
#replot

### Last data plot
# change only plot command here
currentplot = currentplot + 1
set lmargin at screen lft(currentplot,n,w,l,k)
set rmargin at screen rgt(currentplot,n,w,l,k)
set xtics
replot

### Key plot
set lmargin at screen rgt(n,n,w,l,k)
set rmargin at screen 1
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'

unset multiplot
结果如下所示:

尝试设置每个绘图的大小,并增加总绘图的总大小plot@Dinesh我该怎么做?“你们对那个密码有什么想法吗?”安德拉斯,你们所指的那个问题和我的问题毫无关系——非常相似的问题:和。这都是关于使用固定边距的。试着设置每个绘图的大小,并增加总的大小plot@Dinesh我该怎么做?“你们对那个密码有什么想法吗?”安德拉斯,你们所指的那个问题和我的问题毫无关系——非常相似的问题:和。这一切都是关于使用固定的边距。这不是一个可行的方法,因为您仍然可以自动调整边距。这可能会奏效,但要想获得适当的利润率,还需要做很多工作。为了得到正确的结果,必须使用固定的边距。请参见@andyras的答案。这不是一种可行的方法,因为您仍然可以自动调整边距。这可能会奏效,但要想获得适当的利润率,还需要做很多工作。为了得到正确的结果,必须使用固定的边距,见@andyras的答案。