% CWTPlotLabels(nvoice,qscaleArray,spacing,tau,tauticks,t,tticks)
% Makes a figure with the CWT coefficients generated by jlab scripts

function CWTPlotLabels(nvoice,qscaleArray,spacing,tau,tauticks,t,tticks)

set(gca,'YDir','normal','FontSize',16);

Nticks=numel(tticks);
C=cell(1,Nticks);tickind=zeros(1,Nticks);
for k=1:Nticks
    C(1,k)={num2str(tticks(k))};
    tickind(k)=find(t>=tticks(k),1,'first');
end

set(gca,'XTickLabel',C,'XTick',tickind);

xlabel('Time in days ')
ylabel('Period in hours ')

if strcmp(spacing,'uniform')% uniformly spaced period ticks
    qticks=1:round(nvoice/4):numel(qscaleArray);
    C=cell(1,numel(qticks));
    for k=1:numel(qticks)
        C(1,k)={num2str(tau(qticks(k)))};
    end
    
else   % integer valued period ticks
%     tauticks=shortestperiod:ceil((longestperiod-shortestperiod)/4):longestperiod; % integer in middle indicates spacing of ticks
    qticks=interp1(tau,1:numel(qscaleArray),tauticks); % finds scale indices corresponding to those periods
    C=cell(1,numel(qticks));
    for k=1:numel(qticks)
        C(1,k)={num2str(tauticks(k))};
    end
end
set(gca,'YTickLabel',C,'YTick',qticks);