-
Notifications
You must be signed in to change notification settings - Fork 0
/
grapher.m
47 lines (40 loc) · 1.02 KB
/
grapher.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
function [] = grapher(setup,dataSets)
% GRAPHER Multiple plot figure with legend.
% Grapher function is used for simply rendering figure with multiple
% plots and dynamic generated legend.
%
% GRAPHER(setup,dataSets)
%
% setup - 'gsetup' object
% dataSets - cell collection of 'gdataset' objects
%
% See also gsetup, gdataset.
fontSize = 12;
[r,c] = size(dataSets);
leg = cell(1,c);
if c < 2
error('You must add 2 or more datasets!');
end
figure;
plot(dataSets{1}('x'),dataSets{1}('y'));
leg(1) = java.lang.String(dataSets{1}('name'));
hold on;
for i = 2:1:c
plot(dataSets{i}('x'),dataSets{i}('y'));
leg(i) = java.lang.String(dataSets{i}('name'));
end
grid;
title(setup('title'));
xLab = xlabel(setup('labelX'));
yLab = ylabel(setup('labelY'));
legObj = legend(leg);
set(legObj,'FontSize',fontSize);
set(xLab,'FontSize',fontSize);
set(yLab,'FontSize',fontSize);
yLimits = ylim;
yMin = yLimits(1);
yMax = yLimits(2);
yDiff = yMax-yMin;
yMinNew = yMin-(yDiff*0.05);
yMaxNew = yMax+(yDiff*0.05);
ylim([yMinNew yMaxNew]);