% PLot the results of routine DC09_TV_sparsitychoice_comp.m
%
% Samuli Siltanen February 2014

% Plot parameters
fsize   = 21;
msize   = 18;
lwidth  = .4;
lwidth2 = 2;
boxline = 1;
recline = 3;
origline = .5;

% Load precomputed data
load DC09_sparsity truesparsity recx recomat sparsevec alphavec

% Find regularization parameter giving the best sparsity result
pind = max(find(sparsevec>truesparsity));
pind = pind+1;
recosparsity = sparsevec(pind);
disp(alphavec(pind))

% Create plot window
figure(1)
clf

semilogx(alphavec,sparsevec,'r','linewidth',lwidth)
hold on
semilogx(alphavec,sparsevec,'k.','markersize',msize)
semilogx([alphavec(1),alphavec(end)],[truesparsity truesparsity],'k','linewidth',lwidth)
%semilogx([alphavec(1),alphavec(pind)],[recosparsity recosparsity],'k--','linewidth',lwidth)
semilogx([alphavec(pind),alphavec(pind)],[0 recosparsity],'k--','linewidth',lwidth)
axis([alphavec(1) alphavec(end) 0 100])
box off
set(gca,'xtick',10.^[-6:2:4],'fontsize',fsize)
%set(gca,'xticklabel',{},'fontsize',fsize)
set(gca,'ytick',[0 truesparsity 50 100 ],'fontsize',fsize)
set(gca,'PlotBoxAspectRatio' , [2 1 1])


% Create plot window
figure(2)
clf

% Construct original signal for comparison
xx = linspace(0,1,1024);
signal = DC_target(xx);

% Plot original signal
plot(xx,signal,'k','linewidth',lwidth)
hold on

% Take a look at the reconstruction
rec = recomat(:,pind);
plot(recx,rec,'r','linewidth',lwidth2)

% Axis settings
axis([0 1 -.2 1.6])
set(gca,'xtick',[0 1/2 1],'fontsize',fsize)
set(gca,'ytick',[0 .5 1 1.5],'fontsize',fsize)
%set(gca,'xticklabel',{})
%set(gca,'yticklabel',{})
set(gca,'PlotBoxAspectRatio' , [2 1 1])
box off



