-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotSim.m
74 lines (60 loc) · 1.66 KB
/
plotSim.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 success = plotSim(rmses, modparams, folds)
% Prototype: plotSim( rmses, modparams, folds )
%
% Draw a line plot of the cross validation simulation.
%
% [ in ]
%
% @param {rmses} RMSE generated by the crossSim function
% @param {modparams} matrix, set of parameters that were passed to modfit
% @param {folds} matrix (k x 1) of integers
%
% [ out ]
%
% @return a sweet plot
%
% Graph Constants
% Font sizes
LEGEND_SIZE = 14;
LABEL_SIZE = 18;
TITLE_SIZE = 22;
% Colors
BACKGROUND_COLOR = [250,250,250]/255;
COLOR = [1,1,1]*(1- 0.87);
% Color palette for lines, using material design colors
PALETTE = [[211,47,47];[48,63,159];[56,142,60];[230,74,25];[123,31,162]]/255;
% Misc
LINE_WIDTH = pi;
% Drawing
% Initialize plot
p = plot(rmses);
% Label stuff
yLab = ylabel("RMSE");
xLab = xlabel("Folds [k]");
legendLab = legend(arrayfun(@(x) {strcat('Model-', num2str(x))}, modparams));
graphTitle = title('Cross Validation Simulation');
% Set ticks
xtick = 1:length(folds);
set(gca, 'xtick', xtick);
set(gca, 'xticklabel', folds');
% Adjust font sizes
set(xLab, "fontsize", LABEL_SIZE);
set(yLab, "fontsize", LABEL_SIZE);
set(legendLab, "fontsize", LEGEND_SIZE);
set(graphTitle, "fontsize", TITLE_SIZE);
% Tweak Look
legend boxoff;
set(legendLab, "location", "northeastoutside");
set(p, "linewidth", LINE_WIDTH)
% Make it have pretty colors
set(gcf,'Color', BACKGROUND_COLOR);
set(xLab, {'Color'}, COLOR);
set(yLab, {'Color'}, COLOR);
% If the custom palette has sufficiently many colors use it
if length(p) <= length(PALETTE)
for i = 1:length(p)
set(p(i),"color", PALETTE(i,:));
end
endif
% Bask in the glory of the plot
endfunction