简体   繁体   English

在八度中更改图例的位置

[英]Change position of legend in octave

I want to display a legend below or right of multiple subplots, while keeping the aspect ratio of the subplots. 我想在多个子图的下方或右侧显示图例,同时保持子图的长宽比。 Trying the approach of this answer , I wrote the following code: 尝试此答案的方法,我编写了以下代码:

x = [0:0.1:10];

figure();
for i=1:4
  subplot(3,2,i);
  plot(x, x);
endfor;

hSub = subplot(3,2,5:6); 
plot(0);
hLegend = legend('1');
set(hLegend, 'position', get(hSub, 'position'));

which produces: 产生: 输出

The legend should replace the full plot 5. I couldn't find the property position at the octave documentation , so it's obviously not working. 图例应该替换整个图5。我在octave文档中找不到属性position ,因此显然不起作用。

Is there a way to change the legends position or another approach for printing the legend next to the subplots? 有没有一种方法可以更改图例的位置,或者可以使用其他方法在子图旁边打印图例?

edit: 编辑:

  • Octave version: 4.0.3 GUI 八度版本:4.0.3 GUI
  • OS: Opensuse 42.2 操作系统:Opensuse 42.2
  • graphics_toolkit: tested with gnuplot , fltk and qt graphics_toolkit:使用gnuplotfltkqt测试

I guess you want something like 我想你想要类似的东西

x = [0:0.1:10];
figure();
for i=1:4
  subplot(3,2,i);
  plot(x, x);
endfor;

l = legend ("foobar")
hsub = subplot(3,2,5:6);
set (l, "position", get (hsub, "position"))
delete (hsub)

which gives 这使

子图图例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM