Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 其它 > 资料存档
资料存档 资料存档
 
 
主题工具 显示模式
旧 2019-12-10, 20:48   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
帖子 在Matlab中,如何在脚本中放大图

我想使用脚本放大绘图。我只对水平约束缩放感兴趣。所以我想做些类似的事情

p = plot(myData); z = zoom; set(z, 'ZoomInToPoints' , [50 100]); 要么

p = plot(myData); myZoom([50, 100]); 因此,就像使用放大镜工具放大时,这两个功能都可以放大绘图。我只指定两个点,因为我只想水平缩放。

注意,我已经尝试为此使用xlim。虽然有效,但它不允许我在绘图上使用所需的命令text 。



回答:

调用text会将text固定在图形上的一组特定坐标处。致电xlim后,您是否尝试过更新这些内容?

编辑:您可以随时调整文本位置:

x=1:.1:10; y=sin(.1*x); plot(x,y) text(6,.8,'test') %#Sample figure F=get(0,'children'); %#Figure handle A=get(F,'Children'); %#Axes handle T=findobj(A,'Type','text'); %# Text handle oldxlim=xlim; %#grab the original x limits before zoom oldpos=get(T,'Position'); %#get the old text position set(A,'xlim',[5 15]); %#Adjust axes newxlim=xlim; newpos=[(oldpos(1)-oldxlim(1))*(diff(newxlim))... /(diff(oldxlim))+newxlim(1) oldpos(2:end)]; %#interpolate to place the text at the same spot in the axes set(T,'Position',newpos) %#Finally reset the text position 不漂亮,但应该可以。如果每个轴或每个图形的轴有多个注释,则始终可以将以上代码循环放入。



更多&回答...
poster 当前离线   回复时引用此帖
 


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛禁用 表情符号
论坛启用 [IMG] 代码
论坛启用 HTML 代码



所有时间均为北京时间。现在的时间是 04:52


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.