Skip to content

Commit 438ac1b

Browse files
authored
Merge pull request #323 from plotly/issue247_fixed
Issue247 fixed
2 parents 2515f91 + 6367443 commit 438ac1b

File tree

4 files changed

+202
-21
lines changed

4 files changed

+202
-21
lines changed

plotly/plotlyfig.m

+9
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,9 @@ function validate(obj)
623623
for n = 1:obj.State.Figure.NumAxes
624624
try
625625
updateAxis(obj,n);
626+
catch
627+
% TODO to the future
628+
disp('warning: error in updateAxis')
626629
end
627630
end
628631

@@ -635,6 +638,9 @@ function validate(obj)
635638
obj.data{1, n}.opacity = 0.9;
636639
obj.data{1, n}.marker.color = 'rgb(0,113.985,188.955)';
637640
end
641+
catch
642+
% TODO to the future
643+
disp('warning: error using update_opac')
638644
end
639645

640646
end
@@ -643,6 +649,9 @@ function validate(obj)
643649
for n = 1:obj.State.Figure.NumTexts
644650
try
645651
updateAnnotation(obj,n);
652+
catch
653+
% TODO to the future
654+
disp('warning: error in updateAnnotation')
646655
end
647656
end
648657

plotly/plotlyfig_aux/core/updateData.m

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
updateImage(obj, dataIndex);
1212
case 'line'
1313
updateLineseries(obj, dataIndex);
14+
case 'categoricalhistogram'
15+
updateCategoricalHistogram(obj, dataIndex);
1416
case 'histogram'
1517
if strcmpi(obj.State.Axis(dataIndex).Handle.Type, 'polaraxes')
1618
updateHistogramPolar(obj, dataIndex);
@@ -128,6 +130,7 @@
128130
end
129131
catch
130132
% TODO to the future
133+
disp('waring: error in updateData at AXIS/DATA CLEAN UP section')
131134
end
132135

133136
%-------------------------------------------------------------------------%
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
function obj = updateCategoricalHistogram(obj,histIndex)
2+
3+
% x:...[DONE]
4+
% y:...[DONE]
5+
% histnorm:...[DONE]
6+
% name:...[DONE]
7+
% autobinx:...[DONE]
8+
% nbinsx:...[DONE]
9+
% xbins:...[DONE]
10+
% autobiny:...[DONE]
11+
% nbinsy:...[DONE]
12+
% ybins:...[DONE]
13+
% text:...[NOT SUPPORTED IN MATLAB]
14+
% error_y:...[HANDLED BY ERRORBARSERIES]
15+
% error_x:...[HANDLED BY ERRORBARSERIES]
16+
% opacity: --- [TODO]
17+
% xaxis:...[DONE]
18+
% yaxis:...[DONE]
19+
% showlegend:...[DONE]
20+
% stream:...[HANDLED BY PLOTLYSTREAM]
21+
% visible:...[DONE]
22+
% type:...[DONE]
23+
% orientation:...[DONE]
24+
25+
% MARKER:
26+
% color: ...[DONE]
27+
% size: ...[NA]
28+
% symbol: ...[NA]
29+
% opacity: ...[TODO]
30+
% sizeref: ...[NA]
31+
% sizemode: ...[NA]
32+
% colorscale: ...[NA]
33+
% cauto: ...[NA]
34+
% cmin: ...[NA]
35+
% cmax: ...[NA]
36+
% outliercolor: ...[NA]
37+
% maxdisplayed: ...[NA]
38+
39+
% MARKER LINE:
40+
% color: ...[DONE]
41+
% width: ...[DONE]
42+
% dash: ...[NA]
43+
% opacity: ...[TODO]
44+
% shape: ...[NA]
45+
% smoothing: ...[NA]
46+
% outliercolor: ...[NA]
47+
% outlierwidth: ...[NA]
48+
49+
%-------------------------------------------------------------------------%
50+
51+
%-AXIS INDEX-%
52+
axIndex = obj.getAxisIndex(obj.State.Plot(histIndex).AssociatedAxis);
53+
54+
%-HIST DATA STRUCTURE- %
55+
hist_data = get(obj.State.Plot(histIndex).Handle);
56+
57+
%-CHECK FOR MULTIPLE AXES-%
58+
[xsource, ysource] = findSourceAxis(obj,axIndex);
59+
60+
%-AXIS DATA-%
61+
eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']);
62+
eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']);
63+
64+
%-------------------------------------------------------------------------%
65+
66+
%-hist xaxis-%
67+
obj.data{histIndex}.xaxis = ['x' num2str(xsource)];
68+
69+
%-------------------------------------------------------------------------%
70+
71+
%-hist yaxis-%
72+
obj.data{histIndex}.yaxis = ['y' num2str(ysource)];
73+
74+
%-------------------------------------------------------------------------%
75+
76+
%-bar type-%
77+
obj.data{histIndex}.type = 'bar';
78+
79+
%-------------------------------------------------------------------------%
80+
81+
%-hist data-%
82+
obj.data{histIndex}.width = hist_data.BarWidth;
83+
obj.data{histIndex}.y = hist_data.BinCounts;
84+
85+
%-------------------------------------------------------------------------%
86+
87+
%-hist categorical layout on x-axis-%
88+
obj.layout.xaxis1.type = 'category';
89+
obj.layout.xaxis1.autotick = false;
90+
91+
gap = 1 - hist_data.BarWidth;
92+
xmin = -0.5 * gap;
93+
xmax = (hist_data.NumDisplayBins - 1) + 0.5 * gap;
94+
95+
obj.layout.xaxis1.range = {xmin, xmax};
96+
97+
%-------------------------------------------------------------------------%
98+
99+
%-hist name-%
100+
obj.data{histIndex}.name = hist_data.DisplayName;
101+
102+
%-------------------------------------------------------------------------%
103+
104+
%-layout barmode-%
105+
obj.layout.barmode = 'group';
106+
107+
%-------------------------------------------------------------------------%
108+
109+
%-hist line width-%
110+
obj.data{histIndex}.marker.line.width = hist_data.LineWidth;
111+
112+
%-------------------------------------------------------------------------%
113+
114+
%-hist opacity-%
115+
if ~ischar(hist_data.FaceAlpha)
116+
obj.data{histIndex}.opacity = hist_data.FaceAlpha;
117+
end
118+
119+
%-------------------------------------------------------------------------%
120+
121+
obj.data{histIndex}.marker = extractPatchFace(hist_data);
122+
123+
%-------------------------------------------------------------------------%
124+
125+
%-hist visible-%
126+
obj.data{histIndex}.visible = strcmp(hist_data.Visible,'on');
127+
128+
%-------------------------------------------------------------------------%
129+
130+
%-hist showlegend-%
131+
leg = get(hist_data.Annotation);
132+
legInfo = get(leg.LegendInformation);
133+
134+
switch legInfo.IconDisplayStyle
135+
case 'on'
136+
showleg = true;
137+
case 'off'
138+
showleg = false;
139+
end
140+
141+
obj.data{histIndex}.showlegend = showleg;
142+
143+
%-------------------------------------------------------------------------%
144+
145+
end

plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m

+45-21
Original file line numberDiff line numberDiff line change
@@ -70,39 +70,63 @@
7070

7171
%-------------------------------------------------------------------------%
7272

73-
%-contour type-%
74-
obj.data{contourIndex}.type = 'contour';
75-
76-
%-------------------------------------------------------------------------%
77-
7873
%-contour name-%
7974
obj.data{contourIndex}.name = contour_data.DisplayName;
8075

8176
%-------------------------------------------------------------------------%
8277

83-
%-contour x data-%
84-
if ~isvector(contour_data.XData)
85-
obj.data{contourIndex}.x = contour_data.XData(1,:);
86-
else
87-
obj.data{contourIndex}.x = contour_data.XData;
88-
end
78+
%-setting the plot-%
79+
xdata = contour_data.XData;
80+
ydata = contour_data.YData;
81+
zdata = contour_data.ZData;
8982

90-
%-------------------------------------------------------------------------%
83+
if isvector(zdata)
84+
85+
%-contour type-%
86+
obj.data{contourIndex}.type = 'contour';
87+
88+
%-contour x data-%
89+
if ~isvector(x)
90+
obj.data{contourIndex}.xdata = xdata(1,:);
91+
else
92+
obj.data{contourIndex}.xdata = xdata;
93+
end
9194

92-
%-contour y data-%
93-
if ~isvector(contour_data.YData)
94-
obj.data{contourIndex}.y = contour_data.YData(:,1)';
95+
%-contour y data-%
96+
if ~isvector(y)
97+
obj.data{contourIndex}.ydata = ydata';
98+
else
99+
obj.data{contourIndex}.ydata = ydata';
100+
end
101+
102+
%-contour z data-%
103+
obj.data{contourIndex}.z = zdata;
104+
95105
else
96-
obj.data{contourIndex}.y = contour_data.YData';
106+
107+
%-contour type-%
108+
obj.data{contourIndex}.type = 'surface';
109+
110+
%-contour x and y data
111+
[xmesh, ymesh] = meshgrid(xdata, ydata);
112+
obj.data{contourIndex}.x = xmesh;
113+
obj.data{contourIndex}.y = ymesh;
114+
115+
%-contour z data-%
116+
obj.data{contourIndex}.z = zdata;
117+
118+
%-setting for contour lines z-direction-%
119+
obj.data{contourIndex}.contours.z.start = contour_data.LevelList(1);
120+
obj.data{contourIndex}.contours.z.end = contour_data.LevelList(end);
121+
obj.data{contourIndex}.contours.z.size = contour_data.LevelStep;
122+
obj.data{contourIndex}.contours.z.show = true;
123+
obj.data{contourIndex}.contours.z.usecolormap = true;
124+
obj.data{contourIndex}.hidesurface = true;
125+
97126
end
98127

99128
%-------------------------------------------------------------------------%
100129

101-
%-contour z data-%
102-
obj.data{contourIndex}.z = contour_data.ZData;
103-
104-
%-------------------------------------------------------------------------%
105-
106130
%-contour x type-%
107131

108132
obj.data{contourIndex}.xtype = 'array';

0 commit comments

Comments
 (0)