Skip to content

Commit f30218a

Browse files
Fix indentation
1 parent ce4afeb commit f30218a

File tree

139 files changed

+9188
-10589
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+9188
-10589
lines changed

plotly/addtheme.m

+6-13
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,32 @@
11
function f = addtheme(f, theme)
2-
3-
%-------------------------------------------------------------------------%
4-
52
%-validate theme name-%
63

74
themePath = 'plotly/themes';
85
S = dir(themePath);
96

107
if isempty(S)
118
paths = split(path, ':');
12-
139
for p = 1:length(paths)
1410
if ~isempty(strfind(paths{p}, themePath))
1511
themePath = paths{p};
1612
break;
1713
end
1814
end
19-
2015
S = dir(themePath);
2116
end
2217

2318
N = {S.name};
2419

2520
if ~any(strcmp(N,strcat(theme, '.json'))) == 1
26-
ME = MException('MyComponent:noSuchVariable',...
27-
[strcat('\n<strong>', theme,...
28-
'</strong> is not a supported themes.'),...
29-
' Please choose one of these theme names:\n\n',...
30-
strrep(strrep([S.name], '...', ''), '.json', ' | ')]);
21+
ME = MException('MyComponent:noSuchVariable', ...
22+
[strcat('\n<strong>', theme, ...
23+
'</strong> is not a supported themes.'), ...
24+
' Please choose one of these theme names:\n\n', ...
25+
strrep(strrep([S.name], '...', ''), '.json', ' | ')]);
3126
throw(ME)
3227
end
3328

34-
%-------------------------------------------------------------------------%
29+
%---------------------------------------------------------------------%
3530

3631
%-add theme to figure-%
3732

@@ -54,6 +49,4 @@
5449
disp(strcat('layout.plot_bgcolor:::',...
5550
f.layout.template.layout.plot_bgcolor))
5651
end
57-
58-
%-------------------------------------------------------------------------%
5952
end

plotly/fig2plotly.m

+29-36
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,46 @@
11
function p = fig2plotly(varargin)
2+
%----------------------------FIG2PLOTLY-------------------------------%
23

3-
%------------------------------FIG2PLOTLY---------------------------------%
4+
% Convert a MATLAB figure to a Plotly Figure
45

5-
% Convert a MATLAB figure to a Plotly Figure
6+
% [CALL]:
67

7-
% [CALL]:
8+
% p = fig2plotly
9+
% p = fig2plotly(fig_han)
10+
% p = fig2plotly(fig_han, 'property', value, ...)
811

9-
% p = fig2plotly
10-
% p = fig2plotly(fig_han)
11-
% p = fig2plotly(fig_han, 'property', value, ...)
12+
% [INPUTS]: [TYPE]{default} - description/'options'
1213

13-
% [INPUTS]: [TYPE]{default} - description/'options'
14+
% fig_han: [handle]{gcf} - figure handle
15+
% fig_struct: [structure array]{get(gcf)} - figure handle structure
16+
% array
1417

15-
% fig_han: [handle]{gcf} - figure handle
16-
% fig_struct: [structure array]{get(gcf)} - figure handle structure array
18+
% [VALID PROPERTIES / VALUES]:
1719

18-
% [VALID PROPERTIES / VALUES]:
20+
% filename: [string]{'untitled'} - filename as appears on Plotly
21+
% fileopt: [string]{'new'} - 'new, overwrite, extend, append'
22+
% world_readable: [boolean]{true} - public(true) / private(false)
23+
% link: [boolean]{true} - show hyperlink (true) / no hyperlink (false)
24+
% open: [boolean]{true} - open plot in browser (true)
1925

20-
% filename: [string]{'untitled'} - filename as appears on Plotly
21-
% fileopt: [string]{'new'} - 'new, overwrite, extend, append'
22-
% world_readable: [boolean]{true} - public(true) / private(false)
23-
% link: [boolean]{true} - show hyperlink (true) / no hyperlink (false)
24-
% open: [boolean]{true} - open plot in browser (true)
26+
% [OUTPUT]:
2527

26-
% [OUTPUT]:
28+
% p - plotlyfig object
2729

28-
% p - plotlyfig object
30+
% [ADDITIONAL RESOURCES]:
2931

30-
% [ADDITIONAL RESOURCES]:
32+
% For full documentation and examples, see https://plot.ly/matlab
3133

32-
% For full documentation and examples, see https://plot.ly/matlab
34+
%---------------------------------------------------------------------%
3335

34-
%-------------------------------------------------------------------------%
36+
%--FIGURE INITIALIZATION--%
37+
if nargin == 0
38+
varargin{1} = gcf;
39+
end
3540

36-
%--FIGURE INITIALIZATION--%
37-
if nargin == 0
38-
varargin{1} = gcf;
39-
end
40-
41-
%-------------------------------------------------------------------------%
42-
43-
%--CONSTRUCT PLOTLY FIGURE OBJECT--%
44-
p = plotlyfig(varargin{:});
45-
46-
%-------------------------------------------------------------------------%
47-
48-
%--MAKE CALL TO PLOTLY--%
49-
p.plotly;
50-
51-
%-------------------------------------------------------------------------%
41+
%--CONSTRUCT PLOTLY FIGURE OBJECT--%
42+
p = plotlyfig(varargin{:});
5243

44+
%--MAKE CALL TO PLOTLY--%
45+
p.plotly;
5346
end

plotly/getplotlyfig.m

+20-25
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
11
function p = getplotlyfig(file_owner, file_id)
2+
%-----------------------------SAVEPLOTLYFIG---------------------------%
3+
% Grab an online Plotly figure's data/layout information
4+
% [CALL]:
5+
% p = getplotlyfig(file_owner file_id)
6+
% [INPUTS]: [TYPE]{default} - description/'options'
7+
% file_owner: [string]{} - Unique Plotly username
8+
% file_id [int]{} - the id of the graph you want to obtain
9+
% [OUTPUT]:
10+
% p - plotlyfig object
11+
% [EXAMPLE]:
12+
% url: https://plot.ly/~demos/1526
13+
% fig = getplotlyfig('demos','1526');
14+
% [ADDITIONAL RESOURCES]:
15+
% For full documentation and examples, see
16+
% https://plot.ly/matlab/get-requests/
17+
%---------------------------------------------------------------------%
218

3-
%-----------------------------SAVEPLOTLYFIG-------------------------------%
4-
% Grab an online Plotly figure's data/layout information
5-
% [CALL]:
6-
% p = getplotlyfig(file_owner file_id)
7-
% [INPUTS]: [TYPE]{default} - description/'options'
8-
% file_owner: [string]{} - Unique Plotly username
9-
% file_id [int]{} - the id of the graph you want to obtain
10-
% [OUTPUT]:
11-
% p - plotlyfig object
12-
% [EXAMPLE]:
13-
% url: https://plot.ly/~demos/1526
14-
% fig = getplotlyfig('demos','1526');
15-
% [ADDITIONAL RESOURCES]:
16-
% For full documentation and examples, see https://plot.ly/matlab/get-requests/
17-
%-------------------------------------------------------------------------%
18-
19-
%--CONSTRUCT PLOTLY FIGURE OBJECT--%
20-
p = plotlyfig('Visible','off');
21-
22-
%-------------------------------------------------------------------------%
23-
24-
%--MAKE CALL TO DOWNLOAD METHOD--%
25-
p.download(file_owner, file_id);
26-
27-
%-------------------------------------------------------------------------%
19+
%--CONSTRUCT PLOTLY FIGURE OBJECT--%
20+
p = plotlyfig('Visible','off');
2821

22+
%--MAKE CALL TO DOWNLOAD METHOD--%
23+
p.download(file_owner, file_id);
2924
end

plotly/plotly_aux/checkescape.m

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
function escaped_val = checkescape(val)
2-
%adds '\' escape character if needed
3-
ec = '\';
4-
ind = find( (val == '"') | (val == '\' ) | (val == '/' ));
5-
if(ind)
6-
if(ind(1) == 1)
7-
val = ['\' val];
8-
ind = ind + 1;
9-
ind(1) = [];
10-
end
11-
if (ind)
12-
val = [val ec(ones(1,length(ind)))]; %extend lengh of val to prep for char shifts.
13-
for i = 1:length(ind)
14-
val(ind(i):end) = [ec val(ind(i):end-1)];
15-
ind = ind+1;
2+
%adds '\' escape character if needed
3+
ec = '\';
4+
ind = find( (val == '"') | (val == '\' ) | (val == '/' ));
5+
if ind
6+
if ind(1) == 1
7+
val = ['\' val];
8+
ind = ind + 1;
9+
ind(1) = [];
10+
end
11+
if ind
12+
val = [val ec(ones(1,length(ind)))]; %extend lengh of val to prep for char shifts.
13+
for i = 1:length(ind)
14+
val(ind(i):end) = [ec val(ind(i):end-1)];
15+
ind = ind+1;
16+
end
1617
end
1718
end
19+
escaped_val = val;
1820
end
19-
20-
escaped_val = val;

plotly/plotly_aux/getuserdir.m

+14-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
function userDir = getuserdir
2-
% GETUSERDIR Retrieve the user directory
3-
% - Under Windows returns the %APPDATA% directory
4-
% - For other OSs uses java to retrieve the user.home directory
5-
6-
if ispc
7-
% userDir = winqueryreg('HKEY_CURRENT_USER',...
8-
% ['Software\Microsoft\Windows\CurrentVersion\' ...
9-
% 'Explorer\Shell Folders'],'Personal');
10-
userDir = getenv('appdata');
11-
else
12-
userDir = char(java.lang.System.getProperty('user.home'));
13-
end
1+
function userDir = getuserdir
2+
% GETUSERDIR Retrieve the user directory
3+
% - Under Windows returns the %APPDATA% directory
4+
% - For other OSs uses java to retrieve the user.home directory
5+
6+
if ispc
7+
% userDir = winqueryreg('HKEY_CURRENT_USER',...
8+
% ['Software\Microsoft\Windows\CurrentVersion\' ...
9+
% 'Explorer\Shell Folders'],'Personal');
10+
userDir = getenv('appdata');
11+
else
12+
userDir = char(java.lang.System.getProperty('user.home'));
13+
end
14+
end

plotly/plotly_aux/makecall.m

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
function st = makecall(args, origin, structargs)
2-
32
% check if signed in and grab username, key, domain
43
[un, key, domain] = signin;
54
if isempty(un) || isempty(key)
@@ -17,7 +16,9 @@
1716
args = m2json(args);
1817
kwargs = m2json(structargs);
1918
url = [domain '/clientresp'];
20-
payload = {'platform', platform, 'version', plotly_version, 'args', args, 'un', un, 'key', key, 'origin', origin, 'kwargs', kwargs};
19+
payload = {'platform', platform, 'version', plotly_version, ...
20+
'args', args, 'un', un, 'key', key, 'origin', origin, ...
21+
'kwargs', kwargs};
2122

2223
if (is_octave)
2324
% use octave super_powers
@@ -28,7 +29,5 @@
2829
end
2930

3031
st = jsondecode(resp);
31-
3232
response_handler(resp);
33-
34-
end
33+
end

0 commit comments

Comments
 (0)