Mathematica中文论坛-非官方

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 7006|回复: 0
打印 上一主题 下一主题

豆粑粑 matlab subplot 多图大小设置

[复制链接]

532

主题

602

帖子

3031

积分

论坛元老

Rank: 8Rank: 8

积分
3031
跳转到指定楼层
楼主
发表于 2016-10-29 08:55:43 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
自己的问题,subplot总是出问题。

通过 ax设置,可行,
多个子图,每个子图比subplot的默认值大。可以自己定义。

  1. clear all
  2. clc
  3. clf

  4. sbp_width=0.8;
  5. sbp_heig=0.85;
  6. n_row = 4;
  7. n_col = 6;
  8. [out_pos]=fun_mm_subplot_pos(n_row,n_col,sbp_width,sbp_heig);
  9. h=figure(1)
  10. set(h, 'Position', [100, 100, 800, 600]);
  11. [x,y,z]=peaks(30);
  12. caxis_mm=[-5 30];
  13. for i=1:n_row*n_col
  14.     ax=axes('position',out_pos(i,:));
  15.     surf(x,y,z+i,'edgecolor','none')
  16.     caxis(caxis_mm)
  17.     axis tight
  18.     view(0,90)
  19.     hold on
  20.     text([1],[2],[30],mat2str(i),'fontsize',20)
  21. end
  22. colormap(jet)



  23. function [out_pos]=fun_mm_subplot_pos(n_row,n_col,sbp_width,sbp_heig);

  24. % subplot pos
  25. % input : -----------------
  26. % n_row     : number of row
  27. % n_col     : number of column
  28. % sbp_width : subplot width  0-1
  29. % sbp_heig  : subplot height 0-1
  30. % output : ----------------
  31. % out_pos
  32. %
  33. %
  34. % sbp_width=0.8;
  35. % sbp_heig=0.85;
  36. % n_row = 4;
  37. % n_col = 6;
  38. % [out_pos]=fun_mm_subplot_pos(n_row,n_col,sbp_width,sbp_heig);
  39. % h=figure(1)
  40. % set(h, 'Position', [100, 100, 800, 600]);
  41. % [x,y,z]=peaks(30);
  42. % caxis_mm=[-5 30];
  43. % for i=1:n_row*n_col
  44. %     ax=axes('position',out_pos(i,:));
  45. %     surf(x,y,z+i,'edgecolor','none')
  46. %     caxis(caxis_mm)
  47. %     view(0,90)
  48. %     hold on
  49. %     text([2],[2],[30],mat2str(i),'fontsize',20)
  50. % end

  51. for i=1:n_row*n_col

  52.     k1=ceil(i/n_col);
  53.     k2=i-(k1-1)*n_col;
  54.    
  55.     out_pos(i,:)=[(1-sbp_width)/n_col/2 + (k2-1)/n_col,...
  56.                   (1-sbp_heig )/n_row/2 + (n_row-k1)/n_row, ...
  57.                   sbp_width/n_col,...
  58.                   sbp_heig/n_row];
  59. end
复制代码


fig_test_arry_plot.png (173.89 KB, 下载次数: 822)

fig_test_arry_plot.png
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|Mathematica中文论坛-非官方 ( 辽ICP备16001491号-1

GMT+8, 2024-4-29 02:13 , Processed in 0.119979 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表