This repository has been archived by the owner on Apr 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 167
/
Copy pathplot_ordering.m
137 lines (111 loc) · 4.09 KB
/
plot_ordering.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
function handle = plot_ordering(trackers, values, criteria, varargin)
% plot_ordering Generate a per-selector ordering plot.
%
% Generate a per-selector ordering plot for either accuracy of robustness
% for a set of criteria.
%
% Input:
% - trackers (cell): A cell array of tracker structures.
% - values (matrix): Ranking or raw values for trackers.
% - criteria (cell): An array of criteria names.
% - varargin[Title] (string): A title of the plot.
% - varargin[Normalized] (boolean): A sensitivity parameter value.
% - varargin[Visible] (boolean): Is the figure visible on the display.
% - varargin[Width] (double): Figure width hint.
% - varargin[Height] (double): Figure height hint.
% - varargin[Flip] (boolean): Flip the horizontal axsis.
% - varargin[Type] (string): Name of the horizontal axis.
% - varargin[Scope] (double): Maximum number in horizontal axsis.
% - varargin[Handle] (handle): Plot on existing figure handle.
% - varargin[Legend] (boolean): Render plot legend.
%
% Output:
% - handle (handle): A figure handle.
%
plot_title = [];
normalized = 0;
width = 3;
height = max(3, numel(criteria) / 3);
scope = [1, numel(trackers)];
type = 'Rank';
flip = 0;
show_legend = 1;
visible = false;
handle = [];
for i = 1:2:length(varargin)
switch lower(varargin{i})
case 'title'
plot_title = varargin{i+1};
case 'visible'
visible = varargin{i+1};
case 'normalized'
normalized = varargin{i+1};
case 'width'
width = varargin{i+1};
case 'height'
height = varargin{i+1};
case 'scope'
scope = varargin{i+1};
case 'type'
type = varargin{i+1};
case 'flip'
flip = varargin{i+1};
case 'handle'
handle = varargin{i+1};
case 'legend'
show_legend = varargin{i+1};
otherwise
error(['Unknown switch ', varargin{i},'!']) ;
end
end
if isempty(handle)
if ~visible
handle = figure('Visible', 'off');
else
handle = figure();
end
else
figure(handle);
end;
[~, I] = sort(values, 2, 'ascend');
hold on; grid on; box on;
phandles = zeros(1, length(trackers));
if ~normalized
for t = 1:length(trackers)
x = values(:, t);
c = rgb2hsv(trackers{t}.style.color); c(2) = 0.3;
c = hsv2rgb(c);
plot(x, 1:length(criteria), '--', ...
'Color', c, 'LineWidth', trackers{t}.style.width);
end;
for t = 1:length(trackers)
x = values(:, t);
phandles(t) = plot(x, 1:length(criteria), trackers{t}.style.symbol, ...
'Color', trackers{t}.style.color, 'MarkerSize', 10, 'LineWidth', trackers{t}.style.width);
end;
if ~isempty(plot_title)
title(plot_title,'interpreter','none');
end;
else
for t = 1:length(trackers)
x = mod(find(I' == t)-1, length(trackers))+1;
phandles(t) = plot(x, 1:length(criteria), [trackers{t}.style.symbol, '--'], ...
'Color', trackers{t}.style.color, 'MarkerSize', 10, 'LineWidth', trackers{t}.style.width);
end;
if ~isempty(plot_title)
title([plot_title, '(normalized)'],'interpreter', 'none');
end;
end;
plot_labels = cellfun(@(tracker) tracker.label, trackers, 'UniformOutput', 0);
if show_legend
legend(phandles, plot_labels, 'Location', 'NorthEastOutside', 'interpreter', 'none');
end;
xlabel(type);
set(gca,'ytick', 1:numel(criteria),'yticklabel', criteria, 'YDir','Reverse', 'ylim', [0.9, numel(criteria)+0.1]);
set(gca,'xtick', floor(scope(1)):ceil(scope(2)), 'xlim', scope + [-1, 1] * (diff(scope) / 100));
if flip
set(gca, 'xdir', 'reverse');
end;
set(gca, 'LineWidth', 2);
hold off;
set(handle, 'PaperUnits', 'inches', 'PaperSize', [width, height], 'PaperPosition', [0, 0, width, height]);