|
1 |
| -function [response] = fig2plotly(f, plot_name) |
| 1 | +function [response] = fig2plotly(varargin) |
2 | 2 | % 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) |
3 | 7 | % [response] = fig2plotly(f, plot_name)
|
| 8 | +% gcf - root figure object in the form of a double. |
4 | 9 | % f - root figure object in the form of a struct. Use f = get(gcf); to
|
5 | 10 | % get the current figure struct.
|
6 | 11 | % plot_name - a string naming the plot
|
7 | 12 | % response - a struct containing the result info of the plot
|
8 | 13 | %
|
9 | 14 | % For full documentation and examples, see https://plot.ly/api
|
10 | 15 |
|
| 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 | + |
11 | 43 | %convert figure into data and layout data structures
|
12 | 44 | [data, layout] = convertFigure(f);
|
13 | 45 |
|
|
0 commit comments