-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlabel.m
29 lines (26 loc) · 1.02 KB
/
label.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
function fth = label(titlestring, xpos, ypos, varargin)
% xpos and ypos are normalized values between 0 and 1
%% Inputparser
p = inputParser();
p.CaseSensitive = false;
p.addOptional('alignment', 'left');
p.addOptional('verticalalignment', 'bottom');
p.addOptional('Color', 'black');
p.addOptional('fontsize', 12);
p.addOptional('unit', 'normalized');
p.parse(varargin{:});
%%%%%%%%%%%%%%%%%%%%%%%%%%
fontsize = p.Results.fontsize;
col = p.Results.Color;
alignment = p.Results.alignment;
verticalalignment = p.Results.verticalalignment;
unit = p.Results.unit;
%%
% Check if titlestring is numeric and round it to two decimal places if it is
if isnumeric(titlestring)
titlestring = sprintf('%.2f', titlestring);
end
% Create the text label
fth = text(xpos, ypos, titlestring, 'units', unit, 'horizontalalignment', alignment, ...
'verticalalignment', verticalalignment, 'fontsize', fontsize, 'Color', col, 'interpreter', 'latex');
end