-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtextplot.m
More file actions
59 lines (56 loc) · 1.25 KB
/
Copy pathtextplot.m
File metadata and controls
59 lines (56 loc) · 1.25 KB
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
function [h]=textplot(x,y,str,pos,bc,ec,fs,int,units,rot)
% Function to insert text to a plot
% Written: Gerard O'Reilly
% [h]=textplot(x,y,str,pos,bc,ec,fs,int,units,rot)
%
% Input ------
% x: x position
% y: y position
% str: text (string)
% pos: location within (x,y) left/centered/top etc. (string)
% Options: lt, lm, lb, ct, cm, cb, rt, rm, rb
% bc: background color (string)
% ec: edge color (string)
% units: in normalized or absolute units
% rot: rotation of the text in degrees counterclockwise
if nargin<7
fs=16;
end
if nargin<8
int='none';
end
if nargin<9
units='data';
end
if nargin<10
rot=0;
end
if pos=='lt'
ha='left';
va='top';
elseif pos=='lm'
ha='left';
va='middle';
elseif pos=='lb'
ha='left';
va='bottom';
elseif pos=='ct'
ha='center';
va='top';
elseif pos=='cm'
ha='center';
va='middle';
elseif pos=='cb'
ha='center';
va='bottom';
elseif pos=='rt'
ha='right';
va='top';
elseif pos=='rm'
ha='right';
va='middle';
elseif pos=='rb'
ha='right';
va='bottom';
end
h=text(x,y,str,'HorizontalAlignment',ha,'VerticalAlignment',va,'edgecolor',ec,'backgroundcolor',bc,'fontsize',fs,'interpreter',int,'units',units,'rotation',rot);