-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathFigureLHtest.m
115 lines (89 loc) · 2.39 KB
/
FigureLHtest.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
function tests = FigureLHtest
tests = functiontests(localfunctions);
end
%% Subplots
function subPlotTest(tS)
figS = FigureLH('visible', false);
figS.new;
subplot(2,1,1);
figS.plot_line(1:20, sqrt(1:20), 1);
xlabel('x label');
ylabel('$y$ variable');
figS.format;
subplot(2,1,2);
figS.plot_line(1:20, exp(2 - (1 : 20) ./ 10), 1);
xlabel('x label');
ylabel('$y$ variable');
figS.format;
compS = configLH.Computer([]);
figS.save(fullfile(compS.testFileDir, 'FigureLHSubPlotTest'), true);
end
%% Grouped bar graph
function groupedBarTest(testCase)
nx = 4;
ny = 3;
rng('default');
data_xyM = rand(nx, ny);
xLabelV = cell([nx, 1]);
for ix = 1 :nx
xLabelV{ix} = sprintf('x%i', ix);
end
yLabelV = stringLH.vector_to_string_array(1 : ny, 'y%i');
compS = configLH.Computer([]);
isVisible = false;
% isVisible = true;
fS = FigureLH('height', 3.5, 'width', 4.2, 'visible', isVisible, 'figType', 'bar');
fS.new;
% Grouped by y, for which we provide labels
fS.bar_graph(data_xyM, yLabelV)
fS.format;
fS.save(fullfile(compS.testFileDir, 'FigureLHGroupedBarTest'), true);
end
%% Bar graph
function barTest(testCase)
compS = configLH.Computer([]);
isVisible = false;
% isVisible = true;
fS = FigureLH('height', 3.5, 'width', 4.2, 'visible', isVisible, 'figType', 'bar');
fS.new;
bar(1:5, sqrt(1:5)' * linspace(1,2, 4));
fS.text(2, 3, 'Test text');
fS.format;
if isVisible
pause;
end
fS.save(fullfile(compS.testFileDir, 'FigureLHBartest'), true);
fS.close;
end
%% Line graph
function lineTest(testCase)
compS = configLH.Computer([]);
isVisible = false;
% isVisible = true;
fS = FigureLH('height', 3.5, 'width', 4.2, 'visible', isVisible);
fS.set_defaults;
for i1 = 1 : 20
fS.line_style_dense(i1);
fS.line_style(i1);
fS.marker(i1);
fS.line_color(i1);
end
clear fS;
fS = FigureLH('visible', isVisible, 'figNoteV', {'Line 1', 'Line 2'}, 'titleFontSize', 18);
fS.new;
fS.plot_line(1:10, sqrt(1:10), 1);
fS.plot_line(1:10, 0.5 .* sqrt(1:10), 2);
fS.plot_line(1:10, (1:10) .^ 0.3, 3);
fS.plot_line(1:10, (1:10) .^ 0.7, 4);
fS.plot_line(1:10, (1:10) .^ 0.2, 5);
fS.text(2, 3, 'Test text');
xlabel('$\phi(x)$');
ylabel('Normal text');
title('$e^{-x/2} \phi(x)$');
fS.format;
if isVisible
pause;
end
fS.save(fullfile(compS.testFileDir, 'FigureLHtest'), true);
fS.close;
end