我想将这两个图组合在一起,我只想使用一个键。如果我用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
这会产生类似于:
可以看出,由于右侧的图例,一个图形的形状会发生变化。我正在寻找一种方法,只使用图例左侧的图形形状和两个数字。
答案 0 :(得分:5)
这个问题有两个部分,我将分别讨论。
1)我可以对多个图使用相同的密钥吗?
不,除非密钥碰巧对两个图中的数据都相同。例如,两个图中有两条线,其中两条线在两个图中都有标题“一”和“两个”可以共享相同的键;两个图中有一行,每个图中的标题“一”和“两个”在单独的图中不能共享相同的密钥。
2)当我拿到钥匙时,如何让我的多重拼图大小相同?
没有简单的方法可以手动调整图表的大小,或者设置this answer中的功能。
在您的情况下,它可能看起来像:
#!/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 :(得分:0)
请注意,我刚刚提供了示例代码。您可能需要更改它以获得正确的情节。
您可以使用以下示例在多重绘图中设置各个绘图的大小:(这是一个示例,您可能需要使用以获得正确的绘图大小。)
set size 0.8,1.2
尝试为每个单独的地块设置它。
您可以按
设置整体尺寸set terminal postscript enhanced eps 24 color size 10cm,15cm