Skip to content

fix issue with scatter in offline mode #223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
208 changes: 124 additions & 84 deletions plotly/plotlyfig_aux/handlegraphics/updateScatter.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,23 @@ function updateScatter(obj,scatterIndex)
%-CHECK FOR MULTIPLE AXES-%
[xsource, ysource] = findSourceAxis(obj,axIndex);

%-AXIS DATA-%
eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']);
eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']);
if ~isfield(scatter_data,'ZData')

%-------------------------------------------------------------------------%
%-AXIS DATA-%
eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']);
eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']);

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

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

%-------------------------------------------------------------------------%

%-scatter yaxis-%
obj.data{scatterIndex}.yaxis = ['y' num2str(ysource)];
%-scatter yaxis-%
obj.data{scatterIndex}.yaxis = ['y' num2str(ysource)];

end

%-------------------------------------------------------------------------%

Expand All @@ -96,83 +100,119 @@ function updateScatter(obj,scatterIndex)

%-------------------------------------------------------------------------%

%-scatter patch data-%
for m = 1:length(scatter_data)

%---------------------------------------------------------------------%

%-scatter x-%
obj.data{scatterIndex}.x = scatter_data.XData;

%---------------------------------------------------------------------%

%-scatter y-%
obj.data{scatterIndex}.y = scatter_data.YData;

%---------------------------------------------------------------------%

%-scatter z-%
if isHG2()
if isfield(scatter_data,'ZData')
obj.data{scatterIndex}.type = 'scatter3d';
obj.data{scatterIndex}.z = scatter_data.ZData;
%reverse counter
n = length(scatter_data) - m + 1;

%---------------------------------------------------------------------%

%-scatter x-%
if length(scatter_data) > 1
obj.data{scatterIndex}.x(m) = scatter_data(n).XData;
else
obj.data{scatterIndex}.x = scatter_data.XData;
end
end

%---------------------------------------------------------------------%

%-scatter showlegend-%
leg = get(scatter_data.Annotation);
legInfo = get(leg.LegendInformation);

switch legInfo.IconDisplayStyle
case 'on'
showleg = true;
case 'off'
showleg = false;
end

obj.data{scatterIndex}.showlegend = showleg;

%---------------------------------------------------------------------%

%-scatter marker-%
childmarker = extractScatterMarker(scatter_data);

%---------------------------------------------------------------------%

%-line color-%
obj.data{scatterIndex}.marker.line.color = childmarker.line.color;

%---------------------------------------------------------------------%

%-marker color-%
obj.data{scatterIndex}.marker.color = childmarker.color;

%---------------------------------------------------------------------%

%-sizeref-%
obj.data{scatterIndex}.marker.sizeref = childmarker.sizeref;

%---------------------------------------------------------------------%

%-sizemode-%
obj.data{scatterIndex}.marker.sizemode = childmarker.sizemode;

%---------------------------------------------------------------------%

%-symbol-%
obj.data{scatterIndex}.marker.symbol = childmarker.symbol;

%---------------------------------------------------------------------%

%-size-%
obj.data{scatterIndex}.marker.size = childmarker.size*0.1;

%---------------------------------------------------------------------%

%-line width-%
obj.data{scatterIndex}.marker.line.width = childmarker.line.width;

%---------------------------------------------------------------------%

%---------------------------------------------------------------------%

%-scatter y-%
if length(scatter_data) > 1
obj.data{scatterIndex}.y(m) = scatter_data(n).YData;
else
obj.data{scatterIndex}.y = scatter_data.YData;
end

%---------------------------------------------------------------------%

%-scatter z-%
if isHG2()
if isfield(scatter_data,'ZData')
if any(scatter_data.ZData)
if length(scatter_data) > 1
obj.data{scatterIndex}.z(m) = scatter_data(n).ZData;
else
obj.data{scatterIndex}.z = scatter_data.ZData;
end
% overwrite type
obj.data{scatterIndex}.type = 'scatter3d';
end
end
end

%---------------------------------------------------------------------%

%-scatter showlegend-%
leg = get(scatter_data.Annotation);
legInfo = get(leg.LegendInformation);

switch legInfo.IconDisplayStyle
case 'on'
showleg = true;
case 'off'
showleg = false;
end

if ~isfield(scatter_data,'ZData')
obj.data{scatterIndex}.showlegend = showleg;
end

%---------------------------------------------------------------------%

%-scatter marker-%
childmarker = extractScatterMarker(scatter_data(n));

%---------------------------------------------------------------------%

%-line color-%
if length(scatter_data) > 1
obj.data{scatterIndex}.marker.line.color{m} = childmarker.line.color{1};
else
obj.data{scatterIndex}.marker.line.color = childmarker.line.color;
end

%---------------------------------------------------------------------%

%-marker color-%
if length(scatter_data) > 1
obj.data{scatterIndex}.marker.color{m} = childmarker.color{1};
else
obj.data{scatterIndex}.marker.color = childmarker.color;
end

%---------------------------------------------------------------------%

%-sizeref-%
obj.data{scatterIndex}.marker.sizeref = childmarker.sizeref;

%---------------------------------------------------------------------%

%-sizemode-%
obj.data{scatterIndex}.marker.sizemode = childmarker.sizemode;

%---------------------------------------------------------------------%

%-symbol-%
obj.data{scatterIndex}.marker.symbol{m} = childmarker.symbol;

%---------------------------------------------------------------------%

%-size-%
obj.data{scatterIndex}.marker.size = childmarker.size;

%---------------------------------------------------------------------%

%-line width-%

if length(scatter_data) > 1 || ischar(childmarker.line.color)
obj.data{scatterIndex}.marker.line.width(m) = childmarker.line.width;
else
obj.data{scatterIndex}.marker.line.width(1:length(childmarker.line.color)) = childmarker.line.width;
end

%---------------------------------------------------------------------%

end
end

12 changes: 4 additions & 8 deletions plotly/plotlyfig_aux/helpers/extractScatterMarker.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
col = 255*MarkerColor;
markercolor = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')'];
else

switch MarkerColor

case 'none'
Expand All @@ -111,17 +112,16 @@


case 'flat'

for n = 1:length(patch_data.CData)
capCD = max(min(patch_data.CData(1,n),axis_data.CLim(2)),axis_data.CLim(1));

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

markercolor{n} = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')'];

end
markercolor = markercolor{1}
end
end

Expand Down Expand Up @@ -176,8 +176,6 @@
markerlinecolor{n} = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')'];

end

markerlinecolor = markerlinecolor{1}

end
end
Expand All @@ -193,8 +191,6 @@
markerlinecolor{n} = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')'];

end

markerlinecolor = markerlinecolor{1};
end
end

Expand Down