function []=hidensitypro(parent,a,b,varargin)
%show the highest density regions of a 2D scores plot
if size(varargin,1)>0 && strcmp('data',varargin(1))==1
    score=parent.data;
    type='Data';
else
    score=parent.score;
    type='Score';
end

nrows=size(parent.images,1);
scrsz = get(groot,'ScreenSize');
figure('Position',[1 scrsz(4)/2 scrsz(3)/2 scrsz(4)/1.5]);

subplot(2,2,1)
scatter(score(1:5:end,a),score(1:5:end,b),1,[0 0.2 1]);
hold on
scatter(score(2:50:end,a),score(2:50:end,b),1,[0 0.8 1]);
scatter(score(3:200:end,a),score(3:200:end,b),2,[0.8 1 0],'filled');
scatter(score(4:1000:end,a),score(4:1000:end,b),1,[1 0.2 0],'filled');
str = sprintf('%s %d',type,a);
xlabel(str)
str = sprintf('%s %d',type,b);
ylabel(str)
str = sprintf('Cluster Plot');
title(str)
xlim([-inf inf])
ylim([-inf inf])

subplot(2,2,2)
[xy,h]=plotgram(score(:,b));
rotate(h,[0 0 1],270,[0 0 0]);
h.YData=-h.YData;
xlabel('Density')
str = sprintf('%s %d',type,b);
ylabel(str)
ylim([-inf inf])
xlim([-inf inf])

subplot(2,2,3)
plotgram(score(:,a));
set(gca,'YDir','reverse');
ylabel('Density')
str = sprintf('%s %d',type,a);
xlabel(str)
ylim([-inf inf])
xlim([-inf inf])

t=annotation('textbox');
t.Position=[0.55 0.35 0.1 0.1];
t.String={sprintf('Type: Cluster Plot'),sprintf('%s: (%0.0f, %0.0f)',type,a,b),sprintf('Density Projections: Yes'),'Contrast Image: Separate',sprintf('Data Type: %s',type)};
t.EdgeColor='none';

figure;
fused=imfuse(reshape(score(:,a),nrows,[]),reshape(score(:,b),nrows,[]));
imshow(fused)
str = sprintf('Contrast Image: %s (%0.0f, %0.0f)',type,a,b);
title(str);

figure;
scatter(score(2:50:end,a),score(2:50:end,b),3,parent.data(2:50:end,[1 5 2]),'filled');
str = sprintf('%s %d',type,a);
xlabel(str)
str = sprintf('%s %d',type,b);
ylabel(str)
str = sprintf('Clusters: RGB Approximation');
title(str)
xlim([-inf inf])
ylim([-inf inf])
end