From ef95b87121020e595a30b7ce8edb0e64cea6134a Mon Sep 17 00:00:00 2001 From: Gilberto Galvis Date: Sat, 9 Oct 2021 12:15:55 -0400 Subject: [PATCH] fixing issue #391 --- .../handlegraphics/updateLineseries.m | 29 ++++++++++--------- .../plotlyfig_aux/helpers/extractAxisData.m | 6 ++-- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index 009a4693..8146d264 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -76,14 +76,17 @@ function updateLineseries(obj,plotIndex) %-------------------------------------------------------------------------% %-if polar plot or not-% -treatas = obj.PlotOptions.TreatAs; -ispolar = ismember('compass', lower(treatas)) || ismember('ezpolar', lower(treatas)); +treatAs = obj.PlotOptions.TreatAs; +ispolar = ismember('compass', lower(treatAs)) || ismember('ezpolar', lower(treatAs)); %-------------------------------------------------------------------------% %-getting data-% -x = plotData.XData; -y = plotData.YData; +xData = plotData.XData; +yData = plotData.YData; + +if isduration(xData), xData = datenum(xData); end +if isduration(yData), yData = datenum(yData); end %-------------------------------------------------------------------------% @@ -114,20 +117,20 @@ function updateLineseries(obj,plotIndex) %-scatter x-% if ispolar - r = sqrt(x.^2 + y.^2); - obj.data{plotIndex}.r = r; + rData = sqrt(x.^2 + y.^2); + obj.data{plotIndex}.r = rData; else - obj.data{plotIndex}.x = x; + obj.data{plotIndex}.x = xData; end %-------------------------------------------------------------------------% %-scatter y-% if ispolar - theta = atan2(x,y); - obj.data{plotIndex}.theta = -(rad2deg(theta) - 90); + thetaData = atan2(xData,yData); + obj.data{plotIndex}.theta = -(rad2deg(thetaData) - 90); else - obj.data{plotIndex}.y = plotData.YData; + obj.data{plotIndex}.y = yData; end %-------------------------------------------------------------------------% @@ -190,12 +193,12 @@ function updateLineseries(obj,plotIndex) switch legInfo.IconDisplayStyle case 'on' - showleg = true; + showLeg = true; case 'off' - showleg = false; + showLeg = false; end -obj.data{plotIndex}.showlegend = showleg; +obj.data{plotIndex}.showlegend = showLeg; %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/helpers/extractAxisData.m b/plotly/plotlyfig_aux/helpers/extractAxisData.m index 834fbd9a..a00bde76 100644 --- a/plotly/plotlyfig_aux/helpers/extractAxisData.m +++ b/plotly/plotlyfig_aux/helpers/extractAxisData.m @@ -83,8 +83,9 @@ %=========================================================================% %-get tick label data-% - tickValues = eval(sprintf('axisData.%sTick', axisName)); tickLabels = eval(sprintf('axisData.%sTickLabel', axisName)); + tickValues = eval(sprintf('axisData.%sTick', axisName)); + if isduration(tickValues), tickValues = datenum(tickValues); end %-------------------------------------------------------------------------% @@ -111,6 +112,7 @@ %-some tick label settings-% axisLim = eval( sprintf('axisData.%sLim', axisName) ); + if isduration(axisLim), axisLim = datenum(axisLim); end switch axisData.Box case 'on' @@ -132,7 +134,6 @@ %-set tick labels by using tick values and tick texts-% if ~isempty(tickValues) && ~isempty(tickLabels) - axis.tickmode = 'array'; axis.tickvals = tickValues; axis.ticktext = tickLabels; @@ -142,7 +143,6 @@ %-set tick labels by using only tick values-% elseif ~isempty(tickValues) && isempty(tickLabels) - axis.showticklabels = true; axis.tickmode = 'array'; axis.tickvals = tickValues;