Skip to content

Commit eb27df9

Browse files
Merge pull request #224 from plotly/fixing_issue_177
fix issue #177
2 parents b13aaf3 + b8d999d commit eb27df9

File tree

2 files changed

+36
-19
lines changed

2 files changed

+36
-19
lines changed

Diff for: plotly/plotlyfig_aux/handlegraphics/updateScatter.m

+33-16
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,23 @@ function updateScatter(obj,scatterIndex)
6060
%-CHECK FOR MULTIPLE AXES-%
6161
[xsource, ysource] = findSourceAxis(obj,axIndex);
6262

63-
if ~isfield(scatter_data,'ZData')
63+
if isfield(scatter_data,'ZData')
64+
if isempty(scatter_data.ZData)
6465

65-
%-AXIS DATA-%
66-
eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']);
67-
eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']);
66+
%-AXIS DATA-%
67+
eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']);
68+
eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']);
6869

69-
%-------------------------------------------------------------------------%
70+
%-------------------------------------------------------------------------%
7071

71-
%-scatter xaxis-%
72-
obj.data{scatterIndex}.xaxis = ['x' num2str(xsource)];
72+
%-scatter xaxis-%
73+
obj.data{scatterIndex}.xaxis = ['x' num2str(xsource)];
7374

74-
%-------------------------------------------------------------------------%
75+
%-------------------------------------------------------------------------%
7576

76-
%-scatter yaxis-%
77-
obj.data{scatterIndex}.yaxis = ['y' num2str(ysource)];
77+
%-scatter yaxis-%
78+
obj.data{scatterIndex}.yaxis = ['y' num2str(ysource)];
79+
end
7880

7981
end
8082

@@ -154,8 +156,10 @@ function updateScatter(obj,scatterIndex)
154156
showleg = false;
155157
end
156158

157-
if ~isfield(scatter_data,'ZData')
158-
obj.data{scatterIndex}.showlegend = showleg;
159+
if isfield(scatter_data,'ZData')
160+
if isempty(scatter_data.ZData)
161+
obj.data{scatterIndex}.showlegend = showleg;
162+
end
159163
end
160164

161165
%---------------------------------------------------------------------%
@@ -169,7 +173,11 @@ function updateScatter(obj,scatterIndex)
169173
if length(scatter_data) > 1
170174
obj.data{scatterIndex}.marker.line.color{m} = childmarker.line.color{1};
171175
else
172-
obj.data{scatterIndex}.marker.line.color = childmarker.line.color;
176+
if iscell(childmarker.line.color)
177+
obj.data{scatterIndex}.marker.line.color = childmarker.line.color{1};
178+
else
179+
obj.data{scatterIndex}.marker.line.color = childmarker.line.color;
180+
end
173181
end
174182

175183
%---------------------------------------------------------------------%
@@ -194,12 +202,20 @@ function updateScatter(obj,scatterIndex)
194202
%---------------------------------------------------------------------%
195203

196204
%-symbol-%
197-
obj.data{scatterIndex}.marker.symbol{m} = childmarker.symbol;
205+
if length(scatter_data) > 1
206+
obj.data{scatterIndex}.marker.symbol{m} = childmarker.symbol;
207+
else
208+
obj.data{scatterIndex}.marker.symbol = childmarker.symbol;
209+
end
198210

199211
%---------------------------------------------------------------------%
200212

201213
%-size-%
202-
obj.data{scatterIndex}.marker.size = childmarker.size;
214+
if length(scatter_data) > 1
215+
obj.data{scatterIndex}.marker.size = childmarker.size;
216+
else
217+
obj.data{scatterIndex}.marker.size = childmarker.size * 0.15;
218+
end
203219

204220
%---------------------------------------------------------------------%
205221

@@ -208,7 +224,8 @@ function updateScatter(obj,scatterIndex)
208224
if length(scatter_data) > 1 || ischar(childmarker.line.color)
209225
obj.data{scatterIndex}.marker.line.width(m) = childmarker.line.width;
210226
else
211-
obj.data{scatterIndex}.marker.line.width(1:length(childmarker.line.color)) = childmarker.line.width;
227+
obj.data{scatterIndex}.marker.line.width = childmarker.line.width;
228+
% obj.data{scatterIndex}.marker.line.width(1:length(childmarker.line.color)) = childmarker.line.width;
212229
end
213230

214231
%---------------------------------------------------------------------%

Diff for: plotly/plotlyfig_aux/helpers/extractScatterMarker.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
%-MARKER SYMBOL (STYLE)-%
3636
if ~strcmp(patch_data.Marker,'none')
37-
37+
3838
switch patch_data.Marker
3939
case '.'
4040
marksymbol = 'circle';
@@ -169,7 +169,7 @@
169169
for n = 1:length(patch_data.CData)
170170

171171

172-
capCD = max(min(patch_data.CData(1,n),axis_data.CLim(2)),axis_data.CLim(1));
172+
capCD = max(min(patch_data.CData(n),axis_data.CLim(2)),axis_data.CLim(1));
173173
scalefactor = (capCD - axis_data.CLim(1))/diff(axis_data.CLim);
174174
col = 255*(colormap(1 + floor(scalefactor*(length(colormap)-1)),:));
175175

@@ -184,7 +184,7 @@
184184

185185
for n = 1:length(patch_data.CData)
186186

187-
capCD = max(min(patch_data.CData(1,n),axis_data.CLim(2)),axis_data.CLim(1));
187+
capCD = max(min(patch_data.CData(n),axis_data.CLim(2)),axis_data.CLim(1));
188188
scalefactor = (capCD - axis_data.CLim(1))/diff(axis_data.CLim);
189189
col = 255*(colormap(1+floor(scalefactor*(length(colormap)-1)),:));
190190

0 commit comments

Comments
 (0)