-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcaxis_local.m
74 lines (64 loc) · 2.49 KB
/
caxis_local.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
function caxis_local
% (C) Nick Holschuh - University of Washington - 2016 (Nick.Holschuh@gmail.com)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The inputs are:
%
% ________ -
% ________ -
% ________ -
% ________ -
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The outputs are:
%
% ________ -
% ________ -
% ________ -
% ________ -
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The Dependencies are:
%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
xl = get(gca,'xlim');
yl = get(gca,'ylim');
present_plots = get(gca,'Children');
scatter_flag = 0;
for i = 1:length(present_plots)
if length(present_plots(i).Type) == 5
if present_plots(i).Type == 'image'
cinfo = present_plots(i).CData;
xaxis = linspace(present_plots(i).XData(1),present_plots(i).XData(end),length(cinfo(1,:)));
xaxis = xaxis(1:end-1)+(xaxis(2)-xaxis(1))/2;
yaxis = linspace(present_plots(i).YData(1),present_plots(i).YData(end),length(cinfo(:,1)));
yaxis = yaxis(1:end-1)+(yaxis(2)-yaxis(1))/2;
dix = find(xaxis > xl(1) & xaxis < xl(2));
diy = find(yaxis > yl(1) & yaxis < yl(2));
c_opts = present_plots(i).CData(diy,dix);
c_opts(isnan(c_opts)) = mean(mean(c_opts));
caxis([min(min(c_opts)) max(max(c_opts))]);
break
end
elseif length(present_plots(i).Type) == 7
copts = [Inf -Inf];
scatter_flag = 1;
if present_plots(i).Type == 'scatter'
di = find(present_plots(i).XData > xl(1) & present_plots(i).XData < xl(2) & ...
present_plots(i).YData > yl(1) & present_plots(i).YData < yl(2));
copts = [min([copts(1) min(present_plots(i).CData(di))]) ...
max([copts(2) max(present_plots(i).CData(di))])];
elseif present_plots(i).Type == 'surface'
ri = find(present_plots(i).YData > yl(1) & present_plots(i).YData < yl(2));
ci = find(present_plots(i).XData > xl(1) & present_plots(i).XData < xl(2));
copts = [min([copts(1) min(min(present_plots(i).CData(ri,ci)))]) ...
max([copts(2) max(max(present_plots(i).CData(ri,ci)))])];
end
end
end
if scatter_flag == 1
caxis(copts)
end