【问题标题】:Resize/Change Figure Axis Range in Matlab在 Matlab 中调整/更改图形轴范围
【发布时间】:2015-04-24 15:48:03
【问题描述】:

我的 Matlab GUI 中有一个按钮,可以在新图中打开轴图,这是我的代码:

fig=figure;
set(fig, 'Position', [100, 100, 1049, 895]);
h=handles.axes2;
copyobj(h,fig); 
set(gca,'units','pix') 

set(gca,'units','norm') 

但是,新图中的轴非常小:

但是当我尝试在前面代码的底部添加这一行时:

    set(gca,{'Position',[100, 100, 1049, 895]}); % [left bottom right top]

什么都没有改变...我也尝试过更改数字,但轴没有调整大小...

谁能告诉我我做错了什么?

谢谢

【问题讨论】:

  • 没有任何变化,因为值完全相同,对吧?
  • 不,我只是把这些数字作为例子,我之前尝试了不同的数字,但没有任何改变......

标签: matlab resize matlab-figure figure axes


【解决方案1】:

使用轴命令:

% whatever code you have 
plot(x,y,'-o');
% now add limits for the axisX and axisY 
% that combined with the position limit should zoom your picture automatically
% x1, x2, y1, y2 should be actual values like 0.5, 1, -4 etc. whatever you find appropriate
% if it doesnt zoom as you expect - remove the Position setting and see how it looks.
axis([x1 x2 y1 y2]);

有关更多信息,请参阅 matlab 站点中的示例:http://www.mathworks.com/help/matlab/ref/axis.html

【讨论】:

  • 感谢您的回答,知道如何将其放入我的代码中吗?
【解决方案2】:

只是为了了解更多信息,还有其他函数称为 xlimylim 它们可以单独设置轴,而且它们可以自动缩放。

例如,您想放大 x=10 o 100,但不知道预期的 y 值。如您所知,轴命令需要axis([xmin xmax ymin ymax]),但如果您只是这样做

xmin = 10;
xmax = 100;
xlim([xmin, xmax]);

这将放大到适当的 X,并将 Y 自动缩放到适当的大小。

【讨论】:

  • 谢谢你,这对我也有用:)
猜你喜欢
  • 2014-02-27
  • 1970-01-01
  • 2018-11-30
  • 1970-01-01
  • 2012-12-16
  • 1970-01-01
  • 1970-01-01
  • 2020-04-05
  • 1970-01-01
相关资源
最近更新 更多