Skip to content

Commit 2e7c8f3

Browse files
arguments to fig2plotly improved
1 parent 4924560 commit 2e7c8f3

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

Diff for: plotly/fig2plotly.m

+33-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,45 @@
1-
function [response] = fig2plotly(f, plot_name)
1+
function [response] = fig2plotly(varargin)
22
% fig2plotly - plots a matlab figure object with PLOTLY
3+
% [response] = fig2plotly()
4+
% [response] = fig2plotly(gcf)
5+
% [response] = fig2plotly(f)
6+
% [response] = fig2plotly(gcf, plot_name)
37
% [response] = fig2plotly(f, plot_name)
8+
% gcf - root figure object in the form of a double.
49
% f - root figure object in the form of a struct. Use f = get(gcf); to
510
% get the current figure struct.
611
% plot_name - a string naming the plot
712
% response - a struct containing the result info of the plot
813
%
914
% For full documentation and examples, see https://plot.ly/api
1015

16+
%default input
17+
f = get(gcf);
18+
plot_name = 'untitled';
19+
20+
switch numel(varargin)
21+
case 0
22+
case 1
23+
if isa(varargin{1}, 'double')
24+
f = get(varargin{1});
25+
end
26+
if isa(varargin{1}, 'struct')
27+
f = varargin{1};
28+
end
29+
plot_name = 'untitled';
30+
case 2
31+
if isa(varargin{1}, 'double')
32+
f = get(varargin{1});
33+
end
34+
if isa(varargin{1}, 'struct')
35+
f = varargin{1};
36+
end
37+
plot_name = varargin{2};
38+
otherwise
39+
error('Too many arguments!')
40+
end
41+
42+
1143
%convert figure into data and layout data structures
1244
[data, layout] = convertFigure(f);
1345

0 commit comments

Comments
 (0)