Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
我想使用脚本放大绘图。我只对水平约束缩放感兴趣。所以我想做些类似的事情
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 不漂亮,但应该可以。如果每个轴或每个图形的轴有多个注释,则始终可以将以上代码循环放入。 更多&回答... |
![]() |
![]() |