Skip to content

Commit de80bcd

Browse files
Merge pull request #297 from plotly/issue241_fixing
fix issue 241
2 parents 61bf5ae + aff918a commit de80bcd

File tree

3 files changed

+254
-147
lines changed

3 files changed

+254
-147
lines changed

plotly/plotlyfig.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ function delete(obj)
945945
if ~( ...
946946
strcmpi(fieldname,'surface') || strcmpi(fieldname,'scatter3d') ...
947947
|| strcmpi(fieldname,'mesh3d') || strcmpi(fieldname,'bar') ...
948-
|| strcmpi(fieldname,'scatterpolar') ...
948+
|| strcmpi(fieldname,'scatterpolar') || strcmpi(fieldname,'barpolar') ...
949949
)
950950
fprintf(['\nWhoops! ' exception.message(1:end-1) ' in ' fieldname '\n\n']);
951951
end
Lines changed: 135 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -1,146 +1,135 @@
1-
%----UPDATE PLOT DATA/STYLE----%
2-
3-
function obj = updateData(obj, dataIndex)
4-
5-
%-update plot based on plot call class-%
6-
try
7-
8-
switch lower(obj.State.Plot(dataIndex).Class)
9-
10-
%--CORE PLOT OBJECTS--%
11-
case 'image'
12-
updateImage(obj, dataIndex);
13-
case 'line'
14-
updateLineseries(obj, dataIndex);
15-
case 'histogram'
16-
updateHistogram(obj, dataIndex);
17-
case 'histogram2'
18-
updateHistogram2(obj, dataIndex);
19-
case 'patch'
20-
% check for histogram
21-
if isHistogram(obj,dataIndex)
22-
updateHistogram(obj,dataIndex);
23-
else
24-
updatePatch(obj, dataIndex);
25-
end
26-
case 'rectangle'
27-
updateRectangle(obj,dataIndex);
28-
case 'surface'
29-
updateSurfaceplot(obj,dataIndex);
30-
31-
%-GROUP PLOT OBJECTS-%
32-
case 'area'
33-
updateArea(obj, dataIndex);
34-
case 'areaseries'
35-
updateAreaseries(obj, dataIndex);
36-
case 'bar'
37-
updateBar(obj, dataIndex);
38-
case 'barseries'
39-
updateBarseries(obj, dataIndex);
40-
case 'baseline'
41-
updateBaseline(obj, dataIndex);
42-
case {'contourgroup','contour'}
43-
updateContourgroup(obj,dataIndex);
44-
case 'errorbar'
45-
updateErrorbar(obj,dataIndex);
46-
case 'errorbarseries'
47-
updateErrorbarseries(obj,dataIndex);
48-
case 'lineseries'
49-
updateLineseries(obj, dataIndex);
50-
case 'quiver'
51-
updateQuiver(obj, dataIndex);
52-
case 'quivergroup'
53-
updateQuivergroup(obj, dataIndex);
54-
case 'scatter'
55-
updateScatter(obj, dataIndex);
56-
case 'scattergroup'
57-
updateScattergroup(obj, dataIndex);
58-
case 'stair'
59-
updateStair(obj, dataIndex);
60-
case 'stairseries'
61-
updateStairseries(obj, dataIndex);
62-
case 'stem'
63-
updateStem(obj, dataIndex);
64-
case 'stemseries'
65-
updateStemseries(obj, dataIndex);
66-
case 'surfaceplot'
67-
updateSurfaceplot(obj,dataIndex);
68-
69-
%--Plotly supported MATLAB group plot objects--%
70-
case {'hggroup','group'}
71-
% check for boxplot
72-
if isBoxplot(obj, dataIndex)
73-
updateBoxplot(obj, dataIndex);
74-
end
75-
end
76-
77-
catch exception
78-
if obj.UserData.Verbose
79-
fprintf([exception.message '\nWe had trouble parsing the ' obj.State.Plot(dataIndex).Class ' object.\n',...
80-
'This trace might not render properly.\n\n']);
81-
end
82-
end
83-
84-
%------------------------AXIS/DATA CLEAN UP-------------------------------%
85-
86-
%-AXIS INDEX-%
87-
axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis);
88-
89-
%-CHECK FOR MULTIPLE AXES-%
90-
[xsource, ysource] = findSourceAxis(obj,axIndex);
91-
92-
%-AXIS DATA-%
93-
eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']);
94-
eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']);
95-
96-
%-------------------------------------------------------------------------%
97-
98-
% check for xaxis dates
99-
if strcmpi(xaxis.type, 'date')
100-
obj.data{dataIndex}.x = convertDate(obj.data{dataIndex}.x);
101-
end
102-
103-
% check for xaxis categories
104-
if strcmpi(xaxis.type, 'category') && ...
105-
~strcmp(obj.data{dataIndex}.type,'box')
106-
obj.data{dataIndex}.x = get(obj.State.Plot(dataIndex).AssociatedAxis,'XTickLabel');
107-
end
108-
109-
% check for xaxis duration
110-
if strcmpi(xaxis.type, 'duration')
111-
obj.data{dataIndex}.x = convertDuration(obj.data{dataIndex}.x);
112-
xaxis.type = 'category';
113-
end
114-
115-
% check for xaxis duration with input format
116-
if strcmpi(xaxis.type, 'duration - specified format')
117-
obj.data{dataIndex}.x = get(obj.State.Plot(dataIndex).AssociatedAxis,'XTickLabel');
118-
xaxis.type = 'category';
119-
end
120-
%-------------------------------------------------------------------------%
121-
% check for yaxis dates
122-
if strcmpi(yaxis.type, 'date')
123-
obj.data{dataIndex}.y = convertDate(obj.data{dataIndex}.y);
124-
end
125-
126-
% check for yaxis categories
127-
if strcmpi(yaxis.type, 'category') && ...
128-
~strcmp(obj.data{dataIndex}.type,'box')
129-
obj.data{dataIndex}.y = get(obj.State.Plot(dataIndex).AssociatedAxis,'YTickLabel');
130-
end
131-
132-
% check for yaxis duration
133-
if strcmpi(yaxis.type, 'duration')
134-
obj.data{dataIndex}.y = convertDuration(obj.data{dataIndex}.y);
135-
yaxis.type = 'category';
136-
end
137-
138-
% check for yaxis duration with input format
139-
if strcmpi(yaxis.type, 'duration - specified format')
140-
obj.data{dataIndex}.y = get(obj.State.Plot(dataIndex).AssociatedAxis,'YTickLabel');
141-
yaxis.type = 'category';
142-
end
143-
144-
%-------------------------------------------------------------------------%
145-
146-
end
1+
%----UPDATE PLOT DATA/STYLE----%
2+
3+
function obj = updateData(obj, dataIndex)
4+
5+
%-update plot based on plot call class-%
6+
try
7+
switch lower(obj.State.Plot(dataIndex).Class)
8+
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
84+
end
85+
86+
catch exception
87+
if obj.UserData.Verbose
88+
fprintf([exception.message '\nWe had trouble parsing the ' obj.State.Plot(dataIndex).Class ' object.\n',...
89+
'This trace might not render properly.\n\n']);
90+
end
91+
end
92+
93+
%------------------------AXIS/DATA CLEAN UP-------------------------------%
94+
95+
try
96+
%-AXIS INDEX-%
97+
axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis);
98+
99+
%-CHECK FOR MULTIPLE AXES-%
100+
[xsource, ysource] = findSourceAxis(obj,axIndex);
101+
102+
%-AXIS DATA-%
103+
eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']);
104+
eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']);
105+
106+
%---------------------------------------------------------------------%
107+
108+
% check for xaxis dates
109+
if strcmpi(xaxis.type, 'date')
110+
obj.data{dataIndex}.x = convertDate(obj.data{dataIndex}.x);
111+
end
112+
113+
% check for xaxis categories
114+
if strcmpi(xaxis.type, 'category') && ...
115+
~strcmp(obj.data{dataIndex}.type,'box')
116+
obj.data{dataIndex}.x = get(obj.State.Plot(dataIndex).AssociatedAxis,'XTickLabel');
117+
end
118+
119+
% check for yaxis dates
120+
if strcmpi(yaxis.type, 'date')
121+
obj.data{dataIndex}.y = convertDate(obj.data{dataIndex}.y);
122+
end
123+
124+
% check for yaxis categories
125+
if strcmpi(yaxis.type, 'category') && ...
126+
~strcmp(obj.data{dataIndex}.type,'box')
127+
obj.data{dataIndex}.y = get(obj.State.Plot(dataIndex).AssociatedAxis,'YTickLabel');
128+
end
129+
catch
130+
% TODO to the future
131+
end
132+
133+
%-------------------------------------------------------------------------%
134+
135+
end

0 commit comments

Comments
 (0)