我想使用脚本放大情节。我只对水平约束缩放感兴趣。所以我想做一些类似的事情
p = plot(myData);
z = zoom;
set(z, 'ZoomInToPoints' , [50 100]);
or
p = plot(myData);
myZoom([50, 100]);
因此,这些函数中的任何一个都会放大绘图,就像使用放大镜工具放大一样。我只指定两个点,因为我只想水平缩放。
请注意,我已经尝试使用 xlim 来实现此目的。虽然它有效,但它不允许我使用该命令text
在我的地块上,这是我需要的。
致电text
将把文本固定在图表上的一组特定坐标处。您在致电 xlim 后尝试过更新这些吗?
EDIT:您可以随时调整文本位置:
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
不漂亮,但应该可以。如果每个轴或每个图形的轴有多个注释,则始终可以将上述代码放入循环中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)