Changing axes limits in a while loop
Mostrar comentarios más antiguos
Hello everyone,
I've got some code set up to quickly plot some data in 3 subplots and let users cycle through the dataset. I'm trying to implement a dialog box to let users change the zoom on the x-axis, but after setting the limits, the plot springs back to the original axes. Here's my code right now:
figure(figh)
axL = subplot(3,1,1);
axR = subplot(3,1,2);
axRast = subplot(3,1,3);
linkaxes([axL,axR,axRast],'x');
set(axL,'XLimMode','Manual');
j=1;
while j
% SNIP %
plot(axL,x1,y1,'k')
plot(axR,x2,y2,'k')
% SNIP %
plot(axRast,X,Y,ploco(ico));
% SNIP %
response1 = getkey;
j_old=j;
nstims = ds.nrec;
switch response1
case 28 %left arrow, go back
j=j-1;
if j<1;
beep;
j=1;
end
set(axL,'xlim',[starttime endtime])
case 29 %right arrow, advance
j=j+1;
if j>nstims;beep; j=nstims;end
set(axL,'xlim',[starttime endtime])
case 13 %return, also advance
j=j+1;
if j>nstims;beep;j=nstims;end
set(axL,'xlim',[starttime endtime])
case 117 % press U to unzoom
xLims2 = [0,100*ceil(time(end)/100)];
set(axL,'xlim',xLims2);
pan off
case 122 % press Z to zoom; prompt for the X limits and change them.
prompt = {'Enter start time:','Enter end time name:'};
dlg_title = 'Zoom In';
num_lines = 1;
def = {num2str(starttime),num2str(endtime)};
answer = inputdlg(prompt,dlg_title,num_lines,def);
set(axL,'xlim',[str2num(answer{1}) str2num(answer{2})],'XLimMode','Manual')
drawnow;
pan on
case 113 %q means quit and close window
j=0;
close all force;
end
end
It's probably something very silly I'm missing (it's not anything in the SNIPped comments; those are mostly nodes and old code I dont' want to throw out). Is there something I'm not setting right with regards to the axes? I'm completely clueless as to how to proceed. Thanks.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Data Exploration en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!