-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathfindColorbarData.m
More file actions
31 lines (31 loc) · 1.3 KB
/
findColorbarData.m
File metadata and controls
31 lines (31 loc) · 1.3 KB
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
function colorbarDataIndex = findColorbarData(obj, colorbarIndex, colorbarData)
if nargin == 2
%locate index of data associated with colorbar
colorbarDataIndex = find( ...
arrayfun( @(x)eq(x.AssociatedAxis, ...
obj.State.Colorbar(colorbarIndex).AssociatedAxis), ...
obj.State.Plot ...
), ...
1);
%if no matching data index found
if isempty(colorbarDataIndex)
colorbarDataIndex = max(min(colorbarIndex,obj.State.Figure.NumPlots),1);
end
elseif nargin == 3
c = 1; a = 1;
allAxesIndex = zeros(length(colorbarData.Parent.Children), 1);
for n = 1:length(colorbarData.Parent.Children)
if strcmp(colorbarData.Parent.Children(n).Type, 'colorbar')
allColorbarIndex(c) = n;
c = c + 1;
elseif strcmp(colorbarData.Parent.Children(n).Type, 'axes')
allAxesIndex(n) = a;
a = a + 1;
end
end
colorbarAxisIndex = allColorbarIndex(colorbarIndex) + 1;
colorbarAxisIndex = allAxesIndex(colorbarAxisIndex);
colorbarDataIndex = obj.State.Figure.NumAxes - colorbarAxisIndex + 1;
colorbarDataIndex = colorbarDataIndex;
end
end