How can I add scrollbar to the subplots?
I have gone through many tutorials but they seem quite difficult to understand (ex: Scrolling Figure Demo)
Any easier method to implement?
My code looks like the following. It creates two figures ,one for multiple plots and one for subplots. For the case of subplots i wanted to have scroll bar so as i can slide it down. I dont know how to call this function, if i replace the call of addaxis to my function then how would the axis be readjusted without any call to addaxis function.
function readfile
while(1)
q = cell(16,2);
q{1,1}='1B000003AC63A328.txt'; % sensor 1
q{1,2} = 'sensor 1';
q{2,1}='D6000003ACA0AB28.txt';% sensor 2
q{2,2} = 'sensor 2';
q{3,1}='B0000003AC9B8428.txt'; % sensor 3
q{3,2} = 'sensor 3';
q{4,1}='5D000003AC5FEA28.txt';% sensor 4
q{4,2} = 'sensor 4';
q{5,1}='E1000003AC5DA728.txt';% sensor 5
q{5,2} = 'sensor 5';
q{6,1}='BE000003ACA4F828.txt';% sensor 6
q{6,2} = 'sensor 6';
q{7,1}='5F000003AC8C6128.txt';% sensor 7
q{7,2} = 'sensor 7';
q{8,1}='78000003AC77A328.txt';
q{8,2} = 'sensor 8'; % sensor 8
q{9,1}='B2000003AC542A28.txt';% sensor 9
q{9,2} = 'sensor 9';
q{10,1}='EB000003B717F328.txt';% sensor 10
q{10,2} = 'sensor 10';
q{11,1}='86000003AC97AC28.txt';% sensor 11
q{11,2} = 'sensor 11';
q{12,1}='78000003AC748828.txt';% sensor 12
q{12,2} = 'sensor 12';
q{13,1}='A5000003AC905C28.txt';% sensor 20
q{13,2} = 'sensor 20';
q{14,1}='B4000003ACA4A728.txt';% sensor 21
q{14,2} = 'sensor 21';
q{15,1}='14000003AC69A528.txt';% sensor 22
q{15,2} = 'sensor 22';
q{16,1}='99000003AC68F728.txt';% sensor 23
q{16,2} = 'sensor 23';
for j=1:16
fname=q{j};
fid=fopen(fname,'r');
header=fgetl(fid);
data=textscan(fid,'%s','delimiter',';');
fclose(fid);
data=data{:};
day=data(1:3:end);
hour=data(2:3:end);
temp=str2double(data(3:3:end));
time=cellfun(@(x) sprintf('%s %s',day{strcmpi(hour,x)},x),hour,'uniformoutput',0);
% timev=datevec(time,'mm.dd.yyyy HH:MM:SS');
timen=datenum(time,'mm.dd.yyyy HH:MM:SS');
seconds=timen*86400/60;
figure(1)
subplot(5,4,j),
h=plot(seconds-seconds(1),temp,'YDataSource','temp');
legend(h,q{j,2});
grid on
xlabel('Time(mins)');
ylabel('Temp °C');
%subplot(1,1,i),
figure(2)
if(j==1)
r=plot(seconds-seconds(1),temp);
hold on
set(r,'Color','blue','LineWidth',2)
end
if(j==2)
r=plot(seconds-seconds(1),temp);
set(r,'Color','green','LineWidth',2)
end
if(j==3)
r=plot(seconds-seconds(1),temp);
set(r,'Color','red','LineWidth',2)
end
if(j==4)
r=plot(seconds-seconds(1),temp);
set(r,'Color','cyan','LineWidth',2)
end
if(j==5)
r=plot(seconds-seconds(1),temp);
set(r,'Color','magenta','LineWidth',2)
end
if(j==6)
r=plot(seconds-seconds(1),temp);
set(r,'Color','yellow','LineWidth',2)
end
if(j==7)
r=plot(seconds-seconds(1),temp);
set(r,'Color','black','LineWidth',2)
end
if(j==8)
r=plot(seconds-seconds(1),temp,'--');
set(r,'Color','blue','LineWidth',2)
end
if(j==9)
r=plot(seconds-seconds(1),temp,'--');
set(r,'color','green','LineWidth',2)
end
if(j==10)
r=plot(seconds-seconds(1),temp,'--');
set(r,'Color','red','LineWidth',2)
end
if(j==11)
r=plot(seconds-seconds(1),temp,'--');
set(r,'Color','cyan','LineWidth',2)
end
if(j==12)
r=plot(seconds-seconds(1),temp,'--');
hold on
set(r,'Color','magenta','LineWidth',2)
end
if(j==13)
r=plot(seconds-seconds(1),temp,'--');
set(r,'Color','yellow','LineWidth',2)
end
if(j==14)
r=plot(seconds-seconds(1),temp,'--');
set(r,'Color','black','LineWidth',2)
end
if(j==15)
r=plot(seconds-seconds(1),temp,'-.');
set(r,'Color','blue','LineWidth',2)
end
if(j==16)
r=plot(seconds-seconds(1),temp,'-.');
set(r,'Color','green','LineWidth',2)
end
legend('Sensor 1','Sensor 2','Sensor 3','Sensor 4','Sensor 5','Sensor 6',...
'Sensor 7','Sensor 8','Sensor 9','Sensor 10','Sensor 11','Sensor 12','Sensor 20','Sensor 21','Sensor 22','Sensor 23','Location','BestOutside')
end
pause(2*60)
end end