-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathplotly.m
More file actions
68 lines (60 loc) · 1.85 KB
/
plotly.m
File metadata and controls
68 lines (60 loc) · 1.85 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
60
61
62
63
64
65
66
67
68
function [response] = plotly(varargin)
% plotly - create a graph in your plotly account
% [response] = plotly(x1,y1,x2,y2,..., kwargs)
% [response] = plotly({data1, data2, ...}, kwargs)
% x1,y1 - arrays
% data1 - a data struct with styling information
% kwargs - an optional argument struct
%
% See also plotlylayout, plotlystyle, signin, signup
%
% For full documentation and examples, see https://plot.ly/api
origin = 'plot';
offline_given = true;
writeFile = true;
if isstruct(varargin{end})
structargs = varargin{end};
f = fieldnames(structargs);
idx = cellfun(@(x) strcmpi(x, 'offline'), f);
if sum(idx) == 1
offline = structargs.(f{idx});
offline_given = offline;
else
offline = true;
offline_given = offline;
end
if ~any(strcmpi('filename', f))
if offline
structargs.filename = 'untitled';
else
structargs.filename = NaN;
end
end
if ~any(strcmpi('fileopt',f))
structargs.fileopt = NaN;
end
idx = cellfun(@(x) strcmpi(x, 'writefile'),f);
if sum(idx) == 1
writeFile=structargs.(f{idx});
end
args = varargin(1:(end-1));
else
if offline_given
structargs = struct('filename', 'untitled', 'fileopt', NaN);
else
structargs = struct('filename', NaN, 'fileopt', NaN);
end
args = varargin(1:end);
end
if ~writeFile
offline_given = true;
end
if offline_given
obj = plotlyfig(args, structargs);
obj.layout.width = 840;
obj.layout.height = 630;
response = obj.plotly;
else
response = makecall(args, origin, structargs);
end
end