1
+ function cleanFeedTitle(obj )
2
+ % cleanFeedTitle checks all annotations for a title. The first title found
3
+ % is used as the layout.title (Plotly title). This should correspond to the
4
+ % title of the first plot added to the MATLAB figure. As a workaround, only
5
+ % the text is used so that the title appears in the feed. The text color is
6
+ % set so that the Plotly title is hidden from the graph, favouring the
7
+ % annotation title (with its flexibilty over positioning).
8
+
9
+ if ~isempty(obj .State .Figure .NumTexts )
10
+
11
+ % grab the title of the first plot added to the figure.
12
+ first_title_index = find(arrayfun(@(x )(isequal(x .Title , 1 )), ...
13
+ obj .State .Text ), 1 , ' first' );
14
+
15
+ if ~isempty(first_title_index )
16
+
17
+ first_title_handle = obj .State .Text(first_title_index ).Handle;
18
+
19
+ % grab the string of the first title
20
+ first_title = get(first_title_handle , ' String' );
21
+ interp = get(first_title_handle , ' Interpreter' );
22
+ first_title_parsed = parseString(first_title , interp );
23
+
24
+ % use that as the filename
25
+ obj.layout.title = first_title_parsed ;
26
+
27
+ % make the title invisible
28
+ obj.layout.titlefont.color = ' rgba(0,0,0,0)' ;
29
+ end
30
+ end
31
+ end
0 commit comments