diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m index b0658eee..144ab4a2 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m @@ -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 %-------------------------------------------------------------------------% @@ -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 diff --git a/plotly/plotlyfig_aux/helpers/extractScatterMarker.m b/plotly/plotlyfig_aux/helpers/extractScatterMarker.m index 79646a95..0a09c484 100644 --- a/plotly/plotlyfig_aux/helpers/extractScatterMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractScatterMarker.m @@ -93,6 +93,7 @@ col = 255*MarkerColor; markercolor = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; else + switch MarkerColor case 'none' @@ -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 @@ -176,8 +176,6 @@ markerlinecolor{n} = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; end - - markerlinecolor = markerlinecolor{1} end end @@ -193,8 +191,6 @@ markerlinecolor{n} = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; end - - markerlinecolor = markerlinecolor{1}; end end