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

Skip to content

Commit f36c6ba

Browse files
authored
Merge branch 'master' into issue231
2 parents 7d28f50 + ff05431 commit f36c6ba

26 files changed

+1318
-153
lines changed

plotly/addtheme.m

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
function f = addtheme(f, theme)
2+
3+
% validate theme name
4+
5+
S = dir('plotly/themes');
6+
N = {S.name};
7+
8+
if ~any(strcmp(N,strcat(theme, '.json'))) == 1
9+
ME = MException('MyComponent:noSuchVariable',...
10+
[strcat('\n<strong>', theme,...
11+
'</strong> is not a supported themes.'),...
12+
' Please choose one of these theme names:\n\n',...
13+
strrep(strrep([S.name], '...', ''), '.json', ' | ')]);
14+
throw(ME)
15+
end
16+
17+
% add theme to figure
18+
19+
fname = strcat('plotly/themes/', theme, '.json');
20+
fid = fopen(fname);
21+
raw = fread(fid,inf);
22+
str = char(raw');
23+
fclose(fid);
24+
theme_template = jsondecode(str);
25+
26+
f.layout.template = theme_template;
27+
28+
if isfield(f.layout.template.layout, 'paper_bgcolor')
29+
disp(strcat('layout.bg_paper:::',...
30+
f.layout.template.layout.paper_bgcolor))
31+
end
32+
33+
if isfield(f.layout.template.layout, 'plot_bgcolor')
34+
disp(strcat('layout.plot_bgcolor:::',...
35+
f.layout.template.layout.plot_bgcolor))
36+
end
37+
end

plotly/plotlyfig.m

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
obj.PlotOptions.Visible = 'on';
6161
obj.PlotOptions.TriangulatePatch = false;
6262
obj.PlotOptions.StripMargins = false;
63+
obj.PlotOptions.TreatAs = '_';
6364

6465
% offline options
6566
obj.PlotOptions.Offline = true;
@@ -196,6 +197,12 @@
196197
if(strcmpi(varargin{a},'StripMargins'))
197198
obj.PlotOptions.StripMargins = varargin{a+1};
198199
end
200+
if(strcmpi(varargin{a},'TriangulatePatch'))
201+
obj.PlotOptions.TriangulatePatch = varargin{a+1};
202+
end
203+
if(strcmpi(varargin{a},'TreatAs'))
204+
obj.PlotOptions.TreatAs = varargin{a+1};
205+
end
199206
end
200207
end
201208

@@ -549,6 +556,16 @@ function validate(obj)
549556
% find plots of figure
550557
plots = findobj(ax(axrev),'-not','Type','Text','-not','Type','axes','-depth',1);
551558

559+
% get number of nbars for pie3
560+
if strcmpi(obj.PlotOptions.TreatAs, 'pie3')
561+
obj.PlotOptions.nbars = 0;
562+
for i = 1:length(plots)
563+
if strcmpi(getGraphClass(plots(i)), 'surface')
564+
obj.PlotOptions.nbars = obj.PlotOptions.nbars + 1;
565+
end
566+
end
567+
end
568+
552569
% add baseline objects
553570
baselines = findobj(ax(axrev),'-property','BaseLine');
554571

@@ -634,6 +651,9 @@ function validate(obj)
634651
for n = 1:obj.State.Figure.NumAxes
635652
try
636653
updateAxis(obj,n);
654+
catch
655+
% TODO to the future
656+
disp('warning: error in updateAxis')
637657
end
638658
end
639659

@@ -646,6 +666,9 @@ function validate(obj)
646666
obj.data{1, n}.opacity = 0.9;
647667
obj.data{1, n}.marker.color = 'rgb(0,113.985,188.955)';
648668
end
669+
catch
670+
% TODO to the future
671+
disp('warning: error using update_opac')
649672
end
650673

651674
end
@@ -654,6 +677,9 @@ function validate(obj)
654677
for n = 1:obj.State.Figure.NumTexts
655678
try
656679
updateAnnotation(obj,n);
680+
catch
681+
% TODO to the future
682+
disp('warning: error in updateAnnotation')
657683
end
658684
end
659685

@@ -983,13 +1009,7 @@ function delete(obj)
9831009
catch exception
9841010
if obj.UserData.Verbose
9851011
% catch 3D output until integrated into graphref
986-
% if ~( ...
987-
% strcmpi(fieldname,'surface') || strcmpi(fieldname,'scatter3d') ...
988-
% || strcmpi(fieldname,'mesh3d') ...
989-
% || strcmpi(fieldname,'scatterpolar') || strcmpi(fieldname,'barpolar') ...
990-
% )
9911012
fprintf(['\nWhoops! ' exception.message(1:end-1) ' in ' varargin{1} '\n\n']);
992-
% end
9931013
end
9941014
end
9951015
end

plotly/plotlyfig_aux/core/updateAnnotation.m

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,13 @@
9191
%-------------------------------------------------------------------------%
9292

9393
%-text-%
94-
obj.layout.annotations{anIndex}.text = parseString(text_data.String,text_data.Interpreter);
95-
if obj.State.Text(anIndex).Title && isempty(text_data.String)
96-
obj.layout.annotations{anIndex}.text = '<b></b>'; %empty string annotation
94+
if ~strcmpi(obj.PlotOptions.TreatAs, 'pie3')
95+
obj.layout.annotations{anIndex}.text = parseString(text_data.String,text_data.Interpreter);
96+
if obj.State.Text(anIndex).Title && isempty(text_data.String)
97+
obj.layout.annotations{anIndex}.text = '<b></b>'; %empty string annotation
98+
end
99+
else
100+
obj.layout.annotations{anIndex}.text = '<b></b>';
97101
end
98102

99103
%-------------------------------------------------------------------------%

plotly/plotlyfig_aux/core/updateData.m

Lines changed: 98 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -2,85 +2,105 @@
22

33
function obj = updateData(obj, dataIndex)
44

5-
%-update plot based on plot call class-%
65
try
7-
switch lower(obj.State.Plot(dataIndex).Class)
6+
7+
%-update plot based on TreatAs PlotOpts-%
8+
9+
if ~strcmpi(obj.PlotOptions.TreatAs, '_')
10+
if strcmpi(obj.PlotOptions.TreatAs, 'pie3')
11+
updatePie3(obj, dataIndex);
12+
end
13+
14+
%-update plot based on plot call class-%
15+
16+
else
817

9-
%--CORE PLOT OBJECTS--%
10-
case 'image'
11-
updateImage(obj, dataIndex);
12-
case 'line'
13-
updateLineseries(obj, dataIndex);
14-
case 'histogram'
15-
if strcmpi(obj.State.Axis(dataIndex).Handle.Type, 'polaraxes')
16-
updateHistogramPolar(obj, dataIndex);
17-
else
18-
updateHistogram(obj, dataIndex);
19-
end
20-
case 'histogram2'
21-
updateHistogram2(obj, dataIndex);
22-
case 'patch'
23-
% check for histogram
24-
if isHistogram(obj,dataIndex)
25-
updateHistogram(obj,dataIndex);
26-
else
27-
updatePatch(obj, dataIndex);
28-
end
29-
case 'rectangle'
30-
updateRectangle(obj,dataIndex);
31-
case 'surface'
32-
updateSurfaceplot(obj,dataIndex);
33-
34-
%-GROUP PLOT OBJECTS-%
35-
case 'area'
36-
updateArea(obj, dataIndex);
37-
case 'areaseries'
38-
updateAreaseries(obj, dataIndex);
39-
case 'bar'
40-
updateBar(obj, dataIndex);
41-
case 'barseries'
42-
updateBarseries(obj, dataIndex);
43-
case 'baseline'
44-
updateBaseline(obj, dataIndex);
45-
case {'contourgroup','contour'}
46-
updateContourgroup(obj,dataIndex);
47-
case 'errorbar'
48-
updateErrorbar(obj,dataIndex);
49-
case 'errorbarseries'
50-
updateErrorbarseries(obj,dataIndex);
51-
case 'lineseries'
52-
updateLineseries(obj, dataIndex);
53-
case 'quiver'
54-
updateQuiver(obj, dataIndex);
55-
case 'quivergroup'
56-
updateQuivergroup(obj, dataIndex);
57-
case 'scatter'
58-
if strcmpi(obj.State.Axis(dataIndex).Handle.Type, 'polaraxes')
59-
updateScatterPolar(obj, dataIndex);
60-
else
61-
updateScatter(obj, dataIndex);
62-
end
63-
case 'scattergroup'
64-
updateScattergroup(obj, dataIndex);
65-
case 'stair'
66-
updateStair(obj, dataIndex);
67-
case 'stairseries'
68-
updateStairseries(obj, dataIndex);
69-
case 'stem'
70-
updateStem(obj, dataIndex);
71-
case 'stemseries'
72-
updateStemseries(obj, dataIndex);
73-
case 'surfaceplot'
74-
updateSurfaceplot(obj,dataIndex);
75-
case 'implicitfunctionline'
76-
updateLineseries(obj, dataIndex);
77-
78-
%--Plotly supported MATLAB group plot objects--%
79-
case {'hggroup','group'}
80-
% check for boxplot
81-
if isBoxplot(obj, dataIndex)
82-
updateBoxplot(obj, dataIndex);
83-
end
18+
switch lower(obj.State.Plot(dataIndex).Class)
19+
20+
%--CORE PLOT OBJECTS--%
21+
case 'image'
22+
updateImage(obj, dataIndex);
23+
case 'line'
24+
updateLineseries(obj, dataIndex);
25+
case 'categoricalhistogram'
26+
updateCategoricalHistogram(obj, dataIndex);
27+
case 'histogram'
28+
if strcmpi(obj.State.Axis(dataIndex).Handle.Type, 'polaraxes')
29+
updateHistogramPolar(obj, dataIndex);
30+
else
31+
updateHistogram(obj, dataIndex);
32+
end
33+
case 'histogram2'
34+
updateHistogram2(obj, dataIndex);
35+
case 'patch'
36+
% check for histogram
37+
if isHistogram(obj,dataIndex)
38+
updateHistogram(obj,dataIndex);
39+
else
40+
updatePatch(obj, dataIndex);
41+
end
42+
case 'rectangle'
43+
updateRectangle(obj,dataIndex);
44+
case 'surface'
45+
updateSurfaceplot(obj,dataIndex);
46+
case 'functionsurface'
47+
updateFunctionSurface(obj,dataIndex);
48+
case 'implicitfunctionsurface'
49+
updateImplicitFunctionSurface(obj,dataIndex);
50+
51+
%-GROUP PLOT OBJECTS-%
52+
case 'area'
53+
updateArea(obj, dataIndex);
54+
case 'areaseries'
55+
updateAreaseries(obj, dataIndex);
56+
case 'bar'
57+
updateBar(obj, dataIndex);
58+
case 'barseries'
59+
updateBarseries(obj, dataIndex);
60+
case 'baseline'
61+
updateBaseline(obj, dataIndex);
62+
case {'contourgroup','contour'}
63+
updateContourgroup(obj,dataIndex);
64+
case 'functioncontour'
65+
updateFunctionContour(obj,dataIndex);
66+
case 'errorbar'
67+
updateErrorbar(obj,dataIndex);
68+
case 'errorbarseries'
69+
updateErrorbarseries(obj,dataIndex);
70+
case 'lineseries'
71+
updateLineseries(obj, dataIndex);
72+
case 'quiver'
73+
updateQuiver(obj, dataIndex);
74+
case 'quivergroup'
75+
updateQuivergroup(obj, dataIndex);
76+
case 'scatter'
77+
if strcmpi(obj.State.Axis(dataIndex).Handle.Type, 'polaraxes')
78+
updateScatterPolar(obj, dataIndex);
79+
else
80+
updateScatter(obj, dataIndex);
81+
end
82+
case 'scattergroup'
83+
updateScattergroup(obj, dataIndex);
84+
case 'stair'
85+
updateStair(obj, dataIndex);
86+
case 'stairseries'
87+
updateStairseries(obj, dataIndex);
88+
case 'stem'
89+
updateStem(obj, dataIndex);
90+
case 'stemseries'
91+
updateStemseries(obj, dataIndex);
92+
case 'surfaceplot'
93+
updateSurfaceplot(obj,dataIndex);
94+
case 'implicitfunctionline'
95+
updateLineseries(obj, dataIndex);
96+
97+
%--Plotly supported MATLAB group plot objects--%
98+
case {'hggroup','group'}
99+
% check for boxplot
100+
if isBoxplot(obj, dataIndex)
101+
updateBoxplot(obj, dataIndex);
102+
end
103+
end
84104
end
85105

86106
catch exception
@@ -128,6 +148,7 @@
128148
end
129149
catch
130150
% TODO to the future
151+
disp('waring: error in updateData at AXIS/DATA CLEAN UP section')
131152
end
132153

133154
%-------------------------------------------------------------------------%

0 commit comments

Comments
 (0)