From a3379f99cc0d16de7506ee06fc115bb5efbf4f01 Mon Sep 17 00:00:00 2001 From: Gilberto Galvis Date: Mon, 25 Oct 2021 16:17:08 -0400 Subject: [PATCH] fix issue #457 --- .../handlegraphics/updateErrorbar.m | 94 ++++++++----------- .../handlegraphics/updateLineseries.m | 14 +-- .../handlegraphics/updateScatter.m | 1 + plotly/plotlyfig_aux/helpers/date2NumData.m | 7 ++ plotly/plotlyfig_aux/helpers/getStringColor.m | 4 + 5 files changed, 56 insertions(+), 64 deletions(-) create mode 100644 plotly/plotlyfig_aux/helpers/date2NumData.m create mode 100644 plotly/plotlyfig_aux/helpers/getStringColor.m diff --git a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m index 9544b063..d393bdd7 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m @@ -1,75 +1,63 @@ -function obj = updateErrorbar(obj, errorbarIndex) +function obj = updateErrorbar(obj, plotIndex) -% type: ...[DONE] -% symmetric: ...[DONE] -% array: ...[DONE] -% value: ...[NA] -% arrayminus: ...{DONE] -% valueminus: ...[NA] -% color: ...[DONE] -% thickness: ...[DONE] -% width: ...[DONE] -% opacity: ---[TODO] -% visible: ...[DONE] + %-------------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-INITIALIZATION-% -%-ERRORBAR STRUCTURE-% -errorbar_data = get(obj.State.Plot(errorbarIndex).Handle); + %-get data structures-% + plotData = get(obj.State.Plot(plotIndex).Handle); -%-------------------------------------------------------------------------% + %-get error data-% + yPositiveDelta = date2NumData(plotData.YPositiveDelta); + yNegativeDelta = date2NumData(plotData.YNegativeDelta); -%-UPDATE LINESERIES-% -updateLineseries(obj, errorbarIndex); + xPositiveDelta = date2NumData(plotData.XPositiveDelta); + xNegativeDelta = date2NumData(plotData.XNegativeDelta); -%-------------------------------------------------------------------------% + %-------------------------------------------------------------------------% -%-errorbar visible-% -obj.data{errorbarIndex}.error_y.visible = true; -obj.data{errorbarIndex}.error_x.visible = true; + %-set trace-% -%-------------------------------------------------------------------------% + updateLineseries(obj, plotIndex); -%-errorbar type-% -obj.data{errorbarIndex}.error_y.type = 'data'; -obj.data{errorbarIndex}.error_x.type = 'data'; + %-errorbar visible-% + obj.data{plotIndex}.error_y.visible = true; + obj.data{plotIndex}.error_x.visible = true; -%-------------------------------------------------------------------------% + %-errorbar type-% + obj.data{plotIndex}.error_y.type = 'data'; + obj.data{plotIndex}.error_x.type = 'data'; -%-errorbar symmetry-% -obj.data{errorbarIndex}.error_y.symmetric = false; + %-errorbar symmetry-% + obj.data{plotIndex}.error_y.symmetric = false; -%-------------------------------------------------------------------------% -%-errorbar value-% -obj.data{errorbarIndex}.error_y.array = errorbar_data.YPositiveDelta; -obj.data{errorbarIndex}.error_x.array = errorbar_data.XPositiveDelta; + %-------------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-set errorbar data-% -%-errorbar valueminus-% -obj.data{errorbarIndex}.error_y.arrayminus = errorbar_data.YNegativeDelta; -obj.data{errorbarIndex}.error_x.arrayminus = errorbar_data.XNegativeDelta; + obj.data{plotIndex}.error_y.array = yPositiveDelta; + obj.data{plotIndex}.error_x.array = xPositiveDelta; -%-------------------------------------------------------------------------% + obj.data{plotIndex}.error_x.arrayminus = xNegativeDelta; + obj.data{plotIndex}.error_y.arrayminus = yNegativeDelta; -%-errorbar thickness-% -obj.data{errorbarIndex}.error_y.thickness = errorbar_data.LineWidth; -obj.data{errorbarIndex}.error_x.thickness = errorbar_data.LineWidth; + %-------------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-errorbar thickness-% + obj.data{plotIndex}.error_y.thickness = plotData.LineWidth; + obj.data{plotIndex}.error_x.thickness = plotData.LineWidth; -%-errorbar width-% -obj.data{errorbarIndex}.error_y.width = obj.PlotlyDefaults.ErrorbarWidth; -obj.data{errorbarIndex}.error_x.width = obj.PlotlyDefaults.ErrorbarWidth; + %-errorbar width-% + obj.data{plotIndex}.error_y.width = obj.PlotlyDefaults.ErrorbarWidth; + obj.data{plotIndex}.error_x.width = obj.PlotlyDefaults.ErrorbarWidth; -%-------------------------------------------------------------------------% + %-errorbar color-% + errorColor = getStringColor(255*plotData.Color); + obj.data{plotIndex}.error_y.color = errorColor; + obj.data{plotIndex}.error_x.color = errorColor; -%-errorbar color-% -col = 255*errorbar_data.Color; -obj.data{errorbarIndex}.error_y.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; -obj.data{errorbarIndex}.error_x.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; + %-------------------------------------------------------------------------% -%-------------------------------------------------------------------------% - -end \ No newline at end of file +end + \ No newline at end of file diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index 1a230a80..580f6e2f 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -252,17 +252,9 @@ function updateScene(obj, dataIndex) %-------------------------------------------------------------------------% %-scene axis configuration-% - xRange = axisData.XLim; - if isduration(xRange) || isdatetime(xRange), xRange = datenum(xRange); end - scene.xaxis.range = xRange; - - yRange = axisData.YLim; - if isduration(yRange) || isdatetime(yRange), yRange = datenum(yRange); end - scene.yaxis.range = yRange; - - zRange = axisData.ZLim; - if isduration(zRange) || isdatetime(zRange), zRange = datenum(zRange); end - scene.zaxis.range = zRange; + scene.xaxis.range = date2NumData(axisData.XLim); + scene.yaxis.range = date2NumData(axisData.YLim); + scene.zaxis.range = date2NumData(axisData.ZLim); scene.xaxis.zeroline = false; scene.yaxis.zeroline = false; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m index 5125d730..e7cacaf6 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m @@ -13,6 +13,7 @@ function updateScatter(obj,scatterIndex) catch isScatter3D = false; end + %-------------------------------------------------------------------------% %-set trace-% diff --git a/plotly/plotlyfig_aux/helpers/date2NumData.m b/plotly/plotlyfig_aux/helpers/date2NumData.m new file mode 100644 index 00000000..3844a1cc --- /dev/null +++ b/plotly/plotlyfig_aux/helpers/date2NumData.m @@ -0,0 +1,7 @@ +function numData = date2NumData(dateData) + numData = dateData; + + if isduration(dateData) || isdatetime(dateData) + numData = datenum(dateData); + end +end \ No newline at end of file diff --git a/plotly/plotlyfig_aux/helpers/getStringColor.m b/plotly/plotlyfig_aux/helpers/getStringColor.m new file mode 100644 index 00000000..1a1e2ef4 --- /dev/null +++ b/plotly/plotlyfig_aux/helpers/getStringColor.m @@ -0,0 +1,4 @@ +function stringColor = getStringColor(numColor) + + stringColor = sprintf('rgb(%f,%f,%f)', numColor); +end \ No newline at end of file