function Matlabanswer()
t=0:.001:10;
intensity = rand(size(t)).^2.*rand(size(t)).^10+rand(size(t)).^100;
hfig = figure(1);clf
hax(1) = axes(hfig);
plot(hax(1),t,intensity),xlabel('time'),ylabel('instensity');
ylim([0 20])
hax(2) = axes(hfig);
scalePos = [hax(1).Position(1)...
hax(1).Position(2)+hax(1).Position(4)-.1...
.1*hax(1).Position(3)...
.1*hax(1).Position(4)];
hax(2).Position = scalePos;
plot(hax(2),t,zeros(size(t)))
xlim(hax(2),hax(1).XLim)
set(hax(2),'XColor', 'none','YColor','none','color','none')
hanno = annotation('textbox', scalePos-[0 .05 0 0], 'String', ...
['scale ' num2str(.1*(diff(hax(1).XLim))) 'x']);
hanno.LineStyle='none';
hzoom = zoom(hfig);
set(hzoom,'ActionPostCallback',{@myzoomfunction,hax,hanno});
function myzoomfunction(obj,event,AX,AnnoText)
xlim(AX(2),AX(1).XLim);
AnnoText.String=['scale ' num2str(.1*(diff(AX(1).XLim))) 'x'];
1 Comment
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/505815-how-to-set-a-scale-in-a-figure-similiar-to-google-maps#comment_798106
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/505815-how-to-set-a-scale-in-a-figure-similiar-to-google-maps#comment_798106
Sign in to comment.