Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0d507a4

Browse files
fix issue related to add plotly themes (addtheme functionality)
1 parent 5c5c3c6 commit 0d507a4

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

plotly/addtheme.m

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
function f = addtheme(f, theme)
22

3-
% validate theme name
4-
5-
S = dir('plotly/themes');
6-
N = {S.name};
3+
%-------------------------------------------------------------------------%
4+
5+
%-validate theme name-%
6+
7+
themePath = 'plotly/themes';
8+
S = dir(themePath);
9+
10+
if isempty(S)
11+
paths = split(path, ':');
712

13+
for p = 1:length(paths)
14+
if ~isempty(strfind(paths{p}, themePath))
15+
themePath = paths{p};
16+
break;
17+
end
18+
end
19+
20+
S = dir(themePath);
21+
end
22+
23+
N = {S.name};
24+
825
if ~any(strcmp(N,strcat(theme, '.json'))) == 1
926
ME = MException('MyComponent:noSuchVariable',...
1027
[strcat('\n<strong>', theme,...
@@ -13,10 +30,13 @@
1330
strrep(strrep([S.name], '...', ''), '.json', ' | ')]);
1431
throw(ME)
1532
end
33+
34+
%-------------------------------------------------------------------------%
1635

17-
% add theme to figure
36+
%-add theme to figure-%
1837

19-
fname = strcat('plotly/themes/', theme, '.json');
38+
fname = sprintf('%s/%s.json', themePath, theme);
39+
% fname = strcat('plotly/themes/', theme, '.json');
2040
fid = fopen(fname);
2141
raw = fread(fid,inf);
2242
str = char(raw');
@@ -33,5 +53,7 @@
3353
if isfield(f.layout.template.layout, 'plot_bgcolor')
3454
disp(strcat('layout.plot_bgcolor:::',...
3555
f.layout.template.layout.plot_bgcolor))
36-
end
56+
end
57+
58+
%-------------------------------------------------------------------------%
3759
end

0 commit comments

Comments
 (0)