function moveax(ax) % Add move/zoom function to axes. To move x-axis, push mouse left-button at % lower-edge of axis and drag. To move y-axis, push it at left-edge and drag. % To zoom/unzoom axes, use mouse right-button. moveax effects to current axes. % To specify axes handle h, use moveax(h). % % ver.1.0 2006/10/13 by T.T if nargin<1, ax=gca; elseif strncmp(ax,'cb_',3), feval(ax); return; end p.mov=0; p.pnt=[0,0]; p.xl=[0,1]; p.yl=[0,1]; set(ax,'userdata',p); set(get(ax,'parent'),'windowbuttondownfcn',[mfilename,' cb_btndown'],... 'windowbuttonmotionfcn',[mfilename,' cb_btndrag'],... 'windowbuttonupfcn',[mfilename,' cb_btnup']); function cb_btndown ax=get(gcf,'currentaxes'); if isempty(ax), return; end p=get(ax,'userdata'); if ~isstruct(p)|~isfield(p,'mov'), return; end siz=get(gcf,'position'); pos=get(ax,'position'); pos=[siz(3:4).*pos(1:2),siz(3:4).*(pos(1:2)+pos(3:4))]; p.pnt=get(gcf,'currentpoint'); if abs(p.pnt(2)-pos(2))<10&pos(1)