Dear all,
I am working on my first GUI and already [edited] beginning to love it [until here] 🙂 I am not managing it to obtain stable axes. Here is my code [now edited again, sorry].
Take this as input:
[X,Y] = meshgrid(1:200,1:100);A = [peaks(100) peaks(100)];
This is the function:
function [] = mygui(X,Y,A)% place data in structure array so that it is available to each subfunction
S.data.X = X;S.data.Y = Y;S.data.A = A;% set up figure
S.fh = figure('units','pixels',... 'position',[100 100 800 600],... 'menubar','none',... 'name','Manual carving tool',... 'numbertitle','off',... 'resize','off',... 'toolbar','figure');% set up zoom toolbar
S.tbh = findall(S.fh,'Type','uitoolbar'); S.tbhb = findall(S.tbh);delete(S.tbhb([2:9 13:end]));S.tbhb = S.tbhb(10:12);% axes
S.ax = axes('parent',S.fh,... 'Units','pixels',... 'DataAspectRatio',[1 1 1],... 'DataAspectRatioMode','manual',... 'OuterPosition',[0 0 600 600],... 'Position',[0 0 600 600],... 'Xlimmode','auto',... 'Ylimmode','auto',... 'PlotBoxAspectRatio',[1 1 1],... 'PlotBoxAspectRatioMode','manual',... 'Visible','on',... 'Layer','top',... 'Box','on',... 'Visible','on');% display A in axes
S.im = image('parent',S.ax,... 'XData',X(1,:),... 'YData',Y(:,1),... 'CData',A,... 'CDataMapping','scaled',... 'visible','on');
So if I now zoom in, the axes position remains at [0 0 600 600], then, if I zoom out and the image extent becomes smaller than the axes, the axes tighten around the image. If I doubleclick on the image, the original position of the axes appears again. However, I would like the axes to remain at the same position always, disregarding the "zoom history". I am using R2011b on Windows.
Thanks for your help, Anon
Best Answer