function [delaytime,apcount]=PlotAP(data,axon_dia)
subdata=data(data(:,3)==axon_dia,:);
delay=subdata(:,6)-subdata(:,5);
subdata=[subdata,delay];
delaytime = zeros(8,41);
apcount = zeros(8,41);
dia = 0:2.5:100;
cha = 0.3:0.1:1;
for i = 1:41
for j = 1:8
idx1=find(subdata(:,1)==dia(i));
idx2=find((subdata(:,2)<cha(j)+0.05) & (subdata(:,2)>cha(j)-0.05));
idx=intersect(idx1,idx2);
if ~isempty(idx)
delaytime(9-j,i)=subdata(idx,7);
apcount(9-j,i)=subdata(idx,4);
end
end
end
color = apcount>=1;
color = color.*delaytime;
color(color<=5 & color>0)=2;
C = bar3(color);
figure
H = bar3(apcount);
cmap=[0.00196078442968428,0.00196078442968428,0.00196078442968428;0.00196078442968428,0.452941179275513,0.743137300014496;1,1,0.00196078442968428;1,0.969747900962830,0.00196078442968428;1,0.937535047531128,0.00196078442968428;1,0.905322134494782,0.00196078442968428;1,0.873109281063080,0.00196078442968428;1,0.840896368026733,0.00196078442968428;1,0.808683514595032,0.00196078442968428;1,0.776470601558685,0.00196078442968428;1,0.744257748126984,0.00196078442968428;1,0.712044835090637,0.00196078442968428;1,0.679831981658936,0.00196078442968428;1,0.647619068622589,0.00196078442968428;1,0.615406215190888,0.00196078442968428;1,0.583193302154541,0.00196078442968428;1,0.550980448722839,0.00196078442968428;1,0.539299130439758,0.00196078442968428;1,0.527617871761322,0.00196078442968428;1,0.515936613082886,0.00196078442968428;1,0.504255354404450,0.00196078442968428;1,0.492574065923691,0.00196078442968428;1,0.480892807245255,0.00196078442968428;1,0.469211548566818,0.00196078442968428;1,0.457530260086060,0.00196078442968428;1,0.445849001407623,0.00196078442968428;1,0.434167742729187,0.00196078442968428;1,0.422486454248428,0.00196078442968428;1,0.410805195569992,0.00196078442968428;1,0.399123936891556,0.00196078442968428;1,0.387442648410797,0.00196078442968428;1,0.375761389732361,0.00196078442968428;1,0.364080131053925,0.00196078442968428;1,0.352398842573166,0.00196078442968428;1,0.340717583894730,0.00196078442968428;1,0.329036325216293,0.00196078442968428;1,0.317355036735535,0.00196078442968428;1,0.305673778057098,0.00196078442968428;1,0.293992519378662,0.00196078442968428;1,0.282311230897903,0.00196078442968428;1,0.270629972219467,0.00196078442968428;1,0.258948683738709,0.00196078442968428;1,0.247267425060272,0.00196078442968428;1,0.235586166381836,0.00196078442968428;1,0.223904892802238,0.00196078442968428;1,0.212223619222641,0.00196078442968428;1,0.200542360544205,0.00196078442968428;1,0.188861086964607,0.00196078442968428;1,0.177179813385010,0.00196078442968428;1,0.165498554706574,0.00196078442968428;1,0.153817281126976,0.00196078442968428;1,0.142136007547379,0.00196078442968428;1,0.130454733967781,0.00196078442968428;1,0.118773475289345,0.00196078442968428;1,0.107092201709747,0.00196078442968428;1,0.0954109355807304,0.00196078442968428;1,0.0837296694517136,0.00196078442968428;1,0.0720483958721161,0.00196078442968428;1,0.0603671297430992,0.00196078442968428;1,0.0486858598887920,0.00196078442968428;1,0.0370045900344849,0.00196078442968428;1,0.0253233220428228,0.00196078442968428;1,0.0136420531198382,0.00196078442968428;1,0.00196078442968428,0.00196078442968428];
colormap(cmap);
clim=[0 70];
axis off
view([32.1 26]);
for i = 1:length(H)
zdata = get(C(i),'Zdata');
set(H(i),'Cdata',zdata)
set(H(i),'CDataMapping', 'direct');
end
end