forked from PeterRochford/SkillMetricsToolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_markers.m
More file actions
93 lines (87 loc) · 2.98 KB
/
get_markers.m
File metadata and controls
93 lines (87 loc) · 2.98 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
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
87
88
89
90
91
92
93
function marker = get_markers(X,option)
%GET_MARKERS Define markers to use in a pattern diagram
%
% marker = GET_MARKERS(X,OPTION)
% Defines the markers to be used for a pattern diagram.
%
% INPUTS:
% x : x-coordinates of markers
% option : data structure containing option values. (Refer to
% GET_TARGET_DIAGRAM_OPTIONS function for more information.)
% option.axismax : maximum for the X & Y values. Used to limit
% maximum distance from origin to display markers
% option.markerColor : single color to use for all markers (Default: red)
% option.markerKey : key to use when marker labels specified as a map
% option.markerLabel : labels for markers
%
% OUTPUTS:
% marker: returns symbols and colors of markers
if strcmp(option.markerLegend,'on')
% Use markers of different colors and shapes
% Define markers
kind=['+';'o';'x';'s';'d';'^';'v';'p';'*'];
colorm=['b';'r';'g';'c';'m';'y';'k'];
if (length(X) > 70)
disp('You must introduce new markers to plot more than 70 cases.')
disp('The ''marker'' character array needs to be extended inside the code.')
return
end
if length(X) <= length(kind)
% Enough symbols, so use all markers with specified color
n=1;
marker(1:(size(colorm,1)*size(kind,1)),1:2)=' ';
for ic=1:size(colorm,1)
for ik=1:size(kind,1)
marker(n,:)=[kind(ik,:) option.markerColor];
n=n+1;
end
end
else
% Define markers and colors using predefined list
n=1;
marker(1:(size(colorm,1)*size(kind,1)),1:2)=' ';
for ic=1:size(colorm,1)
for ik=1:size(kind,1)
marker(n,:)=[kind(ik,:) colorm(ic,:)];
n=n+1;
end
end
end
else
% Use specified markers
if isfield(option,'markerLabel')
% Get information from markerLabel
markerLabel = option.markerLabel;
if isempty(markerLabel)
error('No marker labels provided.');
end
% Determine what data type used for labels
if isMap(markerLabel)
% map container
if isfield(option,'markerKey')
key = option.markerKey;
else
error('No markerKey specified');
end
if ~isKey(markerLabel,key)
error(['Key not in map: markerLabel(' key ')']);
end
value = markerLabel(key);
if length(value) == 1
marker = [option.markerSymbol value];
else
marker = [value(2) value(1)];
end
elseif iscellstr(markerLabel)
% cell array
marker = [option.markerSymbol option.markerColor];
else
% string array
marker = [option.markerSymbol option.markerColor];
end
else
% default of color dot
marker = [option.markerSymbol option.markerColor];
end
end
end %function get_markers