Mathematica中文论坛-非官方

标题: 豆粑粑 matlab 两个子图大小相等,用一个colorbar, [打印本页]

作者: meatball1982    时间: 2017-5-12 13:56
标题: 豆粑粑 matlab 两个子图大小相等,用一个colorbar,
老问题了,两个子图,现样大小,画第二个子图的colorbar。图就变小了。通过position设置。
  1. clf;
  2. s1=subplot(1,2,1);
  3. surf(peaks(20));
  4. view(0,90)
  5. axis tight

  6. s2=subplot(1,2,2);
  7. surf(peaks(30));
  8. view(0,90)
  9. axis tight
  10. hb = colorbar('location','southoutside');

  11. %% # Solution:
  12. s1Pos = get(s1,'position');
  13. s2Pos = get(s2,'position');
  14. s2Pos(3:4) = [s1Pos(3:4)];
  15. set(s2,'position',s2Pos);

  16. %% # Alternative method. Brute force placement
  17. set(s1,'Units','normalized', 'position', [0.1 0.25 0.3 0.6]);
  18. set(s2,'Units','normalized', 'position', [0.5 0.25 0.3 0.6]);
  19. set(hb,'Units','normalized', 'position', [0.15 0.1 0.6 0.05]);
复制代码


fig_bottom_one_colorbar.png (133.45 KB, 下载次数: 1002)

fig_bottom_one_colorbar.png





欢迎光临 Mathematica中文论坛-非官方 (http://www.ilovemathematica.com/) Powered by Discuz! X3.2