![]() |
在Matlab中,如何在脚本中放大图
我想使用脚本放大绘图。我只对水平约束缩放感兴趣。所以我想做些类似的事情
p = plot(myData); z = zoom; set(z, 'ZoomInToPoints' , [50 100]); 要么 p = plot(myData); myZoom([50, 100]); 因此,就像使用放大镜工具放大时,这两个功能都可以放大绘图。我只指定两个点,因为我只想水平缩放。 注意,我已经尝试为此使用xlim。虽然有效,但它不允许我在绘图上使用所需的命令text 。 [B]回答:[/B] 调用text会将text固定在图形上的一组特定坐标处。致电xlim后,您是否尝试过更新这些内容? [B]编辑:[/B]您可以随时调整文本位置: 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 不漂亮,但应该可以。如果每个轴或每个图形的轴有多个注释,则始终可以将以上代码循环放入。 [url=https://stackoverflow.com/questions/3390159]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 01:06。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.