forked from plotly/plotly_matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextractDataAnnotation.m
More file actions
52 lines (41 loc) · 1.05 KB
/
extractDataAnnotation.m
File metadata and controls
52 lines (41 loc) · 1.05 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
function data = extractDataAnnotation(d, xid, yid, strip_style)
% extractDataAnnotation - create a general purpose annotation struct
% [data] = extractDataAnnotation(d, xid, yid)
% xid,yid - reference axis indices
% d - a data struct from matlab describing an annotation
% data - a plotly annotation struct
%
% For full documentation and examples, see https://plot.ly/api
data = {};
if numel(d.String)==0
return
end
% set reference axis
if xid==1
xid=[];
end
if yid==1
yid=[];
end
data.xref = ['x' num2str(xid)];
data.yref = ['y' num2str(yid)];
%TEXT
data.text = parseText(d.String);
if ~strip_style
if strcmp(d.FontUnits, 'points')
data.font.size = 1.3*d.FontSize;
end
data.font.color = parseColor(d.Color);
%TODO: add font type
end
%POSITION
%use center of bounding box as reference
data.x = d.Extent(1)+d.Extent(3)/2;
data.y = d.Extent(2)+d.Extent(4)/2;
data.align = d.HorizontalAlignment;
data.xanchor = 'center';
data.yanchor = 'middle';
%ARROW
data.showarrow = false;
%TODO: if visible, set ax, ay
end