matlab get(gcf,'postion ')相关解释

先看实例:

%% plot
figure;
kSet=[1:30]';
 plot(kSet,acc_pca,'-+',...
     kSet,acc_pcal1,'-s',...
     kSet,acc_2dpca,'-v',...
     kSet,acc_2dpcal1,'-*',...
     kSet,acc_2dpcal1s,'-o');
pos=get(gcf,'Position');
scale=1.2;
set(gcf,'Position',[pos(1),pos(2),pos(3)/scale,pos(4)/scale]);
legend('PCA','PCA-L1','2DPCA','2DPCA-L1','2DPCAL1S','location','Southeast');
xlabel('Number of extracted basis vectors');
ylabel('Classification accuracy');
saveas(gcf,sprintf('demo_classify_%s',face_name),'epsc2');
saveas(gcf,sprintf('demo_classify_%s',face_name));%默认的图片格式fig

这里写图片描述

解读pos=get(gcf,'Position');

gcf:当前图窗的句柄

fig = gcf; % current figure handle
fig.Color = [0 0.5 0.5];
fig.ToolBar = 'none';

gca:当前坐标区或图

ax = gca; % current axes
ax.FontSize = 12;
ax.TickDir = 'out';
ax.TickLength = [0.02 0.02];
ax.YLim = [-2 2];

结果:

>> gcf

ans = 

  Figure (1) (具有属性):

      Number: 1
        Name: ''
       Color: [0.9400 0.9400 0.9400]
    Position: [680 558 560 420]
       Units: 'pixels'
>> gca

ans = 

  Axes (具有属性):

             XLim: [0 1]
             YLim: [0 1]
           XScale: 'linear'
           YScale: 'linear'
    GridLineStyle: '-'
         Position: [0.1300 0.1100 0.7750 0.8150]
            Units: 'normalized'

gcf参数控制[pos(1) pos(2)]为绘图区域左下点的坐标 pos(3):长 pos(4):宽
gca的position很像,自己领悟

下面我们带来一些直观上的感受:
原来

这里写图片描述

set(gcf,'Position',[pos(1),pos(2),pos(3)/2,pos(4)/2])

设置后

这里写图片描述


原来:

这里写图片描述

 set(gca,'Position',[pos(1),pos(2),pos(3)/2,pos(4)/2])

设置后:
这里写图片描述

  • 10
    点赞
  • 41
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值