/
get_taylor_diagram_axes.m
86 lines (78 loc) · 2.34 KB
/
get_taylor_diagram_axes.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
77
78
79
80
81
82
83
84
85
86
function [axes, cax, option] = get_taylor_diagram_axes(rho,option)
%GET_TAYLOR_DIAGRAM_AXES Get axes value for taylor_diagram function.
%
% [AXES,OPTION] = GET_TAYLOR_DIAGRAM_AXES(RHO,OPTION)
% Determines the axes information for a Taylor diagram given the axis
% values (X,Y) and the options in the data structure OPTION returned by
% the GET_TAYLOR_DIAGRAM_OPTIONS function.
%
% INPUTS:
% rho : radial coordinate
% option : data structure containing option values. (Refer to
% GET_TAYLOR_DIAGRAM_OPTIONS function for more information.)
%
% OUTPUTS:
% cax : handle for current axes
% axes : data structure containing axes information for Taylor diagram
% axes.dx : observed standard deviation
% axes.next : directive on how to add next plot
% axes.rinc : increment for radial coordinate
% axes.rmax : maximum value for radial coordinate
% axes.rmin : minimum value for radial coordinate
% axes.tc : color for x-axis
% option : data structure containing updated option values
axes.dx = rho(1);
%% BEGIN THE PLOT HERE TO GET AXIS VALUES:
hold off
cax = gca;
axes.tc = get(cax,'xcolor');
axes.next = lower(get(cax,'NextPlot'));
% make a radial grid
hold(cax,'on');
if ~isfield(option, 'axismax')
maxrho = max(abs(rho(:)));
else
maxrho = option.axismax;
end
% Determine default number of tick marks
if strcmp(option.overlay,'off')
xlim([-maxrho maxrho]);
xt = xticks;
dx = xt(2) - xt(1);
if xt(1) > -maxrho
xt = [xt(1) - dx; xt(:)];
end
if xt(end) < maxrho
xt = [xt(:); xt(end) + dx];
end
else
xt = xticks;
end
ticks = sum(xt >= 0);
% check radial limits and ticks
axes.rmin = 0;
if ~isfield(option, 'axismax')
axes.rmax = xt(end);
option.axismax = axes.rmax;
else
axes.rmax = option.axismax;
end
rticks = max(ticks-1,2);
if rticks > 5 % see if we can reduce the number
if rem(rticks,2) == 0
rticks = rticks/2;
elseif rem(rticks,3) == 0
rticks = rticks/3;
end
end
axes.rinc = (axes.rmax - axes.rmin)/rticks;
tick = (axes.rmin + axes.rinc):axes.rinc:axes.rmax;
if ~isfield(option, 'tickRMS')
option.tickRMS = tick; option.rincRMS = axes.rinc;
end
if ~isfield(option, 'tickSTD')
option.tickSTD = tick; option.rincSTD = axes.rinc;
end
% Set figure background to white
set(gcf,'color','w');
end % function get_taylor_diagram_axes