-
Notifications
You must be signed in to change notification settings - Fork 25
/
get_markers.m
104 lines (97 loc) · 3.49 KB
/
get_markers.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
function [markerSymbol, markerColor] = 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:
% markerSymbol: returns marker symbols
% markerColor: returns marker RGB colors
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']; % short names
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;
markerSymbol(1:(size(colorm,1)*size(kind,1)))=' ';
markerColor=zeros(size(colorm,1)*size(kind,1),3); %store as RGB
for ic=1:size(colorm,1)
for ik=1:size(kind,1)
markerSymbol(n)=kind(ik,:);
markerColor(n,:)=option.markerColor;
n=n+1;
end
end
else
% Define markers and colors using predefined list
n=1;
markerSymbol(1:(size(colorm,1)*size(kind,1)))=' ';
markerColor=zeros(size(colorm,1)*size(kind,1),3); %store as RGB
for ic=1:size(colorm,1)
for ik=1:size(kind,1)
markerSymbol(n)=kind(ik,:);
markerColor(n,:)=validatecolor(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);
mColor = check_color(value);
if length(value) == 1
markerSymbol = option.markerSymbol;
markerColor = mColor;
else
markerSymbol = value(2);
markerColor = validatecolor(value(1));
end
elseif iscellstr(markerLabel) || isstring(markerLabel)
% cell array
markerSymbol = option.markerSymbol;
markerColor = option.markerColor;
else
markerSymbol = option.markerSymbol;
markerColor = option.markerColor;
end
else
% default of color dot
markerSymbol = option.markerSymbol;
markerColor = option.markerColor;
end
end
end %function get_markers