-
Notifications
You must be signed in to change notification settings - Fork 12
/
ID_legend.m
76 lines (67 loc) · 2.08 KB
/
ID_legend.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
function ID_legend(hID,p)
figure(hID);clf
% set up column sizes
rowCount = size(p.colorTab,1);
if isempty(p.mySpID)
colCount = 2;
w = [.75,.25];
else
colCount = 3;
w = [.3,.2,.5];
end
h = 1/(rowCount+1);% +1 to save room for title
% Set up window placement & size on screen
defaultPos=[0,0.2,0.03*colCount,.02*rowCount];
% open and setup figure window
h10 = set(hID, ...
'NumberTitle','off', ...
'Name','ID Legend',...
'Units','normalized',...
'MenuBar','none',...
'Position',defaultPos);
% Write heading
labelStr = 'ID Color Legend';
txtPos = [0 1-h 1 h];
h10handles.headTxt = uicontrol(hID, ...
'Style','text', ...
'Units','normalized', ...
'Position',txtPos, ...
'String',labelStr, ...
'FontUnits','normalized',...
'FontSize',.75,...
'FontWeight','bold');
% Put each color on a row
for iColor = 1:rowCount
patchPos=[0, 1-((iColor+1)*h), w(1), h];
h10handles.colorbox{iColor} = uicontrol(hID,...
'Style','text',...
'Units','normalized',...
'Position',patchPos,...
'BackgroundColor',p.colorTab(iColor,:),...
'String','',...
'FontUnits','normalized');
labelPos=[w(1), 1-((iColor+1)*h), w(2), h];
h10handles.colorLabel{iColor} = uicontrol(hID,...
'Style','text',...
'Units','normalized',...
'Position',labelPos,...
'String',num2str(iColor),...
'FontUnits','normalized',...
'FontSize',.5,...
'FontWeight','bold');
if ~isempty(p.mySpID)
% if species labels are provided, add them as 3rd column
if iColor<= length(p.mySpID)
spPos=[sum(w(1:2)), 1-((iColor+1)*h), w(3), h];
h10handles.spLabel{iColor} = uicontrol(hID,...
'Style','text',...
'Units','normalized',...
'Position',spPos,...
'String',p.mySpID{iColor},...
'FontUnits','normalized',...
'FontSize',.5,...
'FontWeight','bold',...
'HorizontalAlignment','left');
end
end
end