From 67016b63fa928761d8c317e8f5eb39bf2f7c55b2 Mon Sep 17 00:00:00 2001 From: Gilberto Galvis Date: Thu, 5 Aug 2021 09:11:01 -0400 Subject: [PATCH 1/3] fix issue 241 --- plotly/plotlyfig.m | 2 +- plotly/plotlyfig_aux/core/updateData.m | 6 +- .../handlegraphics/updateHistogramPolar.m | 118 ++++++++++++++++++ 3 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m diff --git a/plotly/plotlyfig.m b/plotly/plotlyfig.m index 41d4ed3f..364a3698 100644 --- a/plotly/plotlyfig.m +++ b/plotly/plotlyfig.m @@ -945,7 +945,7 @@ function delete(obj) if ~( ... strcmpi(fieldname,'surface') || strcmpi(fieldname,'scatter3d') ... || strcmpi(fieldname,'mesh3d') || strcmpi(fieldname,'bar') ... - || strcmpi(fieldname,'scatterpolar') ... + || strcmpi(fieldname,'scatterpolar') || strcmpi(fieldname,'barpolar') ... ) fprintf(['\nWhoops! ' exception.message(1:end-1) ' in ' fieldname '\n\n']); end diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 8c881d1e..8a45a174 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -12,7 +12,11 @@ case 'line' updateLineseries(obj, dataIndex); case 'histogram' - updateHistogram(obj, dataIndex); + if strcmpi(obj.State.Axis(dataIndex).Handle.Type, 'polaraxes') + updateHistogramPolar(obj, dataIndex); + else + updateHistogram(obj, dataIndex); + end case 'histogram2' updateHistogram2(obj, dataIndex); case 'patch' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m new file mode 100644 index 00000000..e25d6f18 --- /dev/null +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m @@ -0,0 +1,118 @@ +function obj = updateHistogramPolar(obj,histIndex) + +% x:...[DONE] +% y:...[DONE] +% histnorm:...[DONE] +% name:...[DONE] +% autobinx:...[DONE] +% nbinsx:...[DONE] +% xbins:...[DONE] +% autobiny:...[DONE] +% nbinsy:...[DONE] +% ybins:...[DONE] +% text:...[NOT SUPPORTED IN MATLAB] +% error_y:...[HANDLED BY ERRORBARSERIES] +% error_x:...[HANDLED BY ERRORBARSERIES] +% opacity: --- [TODO] +% xaxis:...[DONE] +% yaxis:...[DONE] +% showlegend:...[DONE] +% stream:...[HANDLED BY PLOTLYSTREAM] +% visible:...[DONE] +% type:...[DONE] +% orientation:...[DONE] + +% MARKER: +% color: ...[DONE] +% size: ...[NA] +% symbol: ...[NA] +% opacity: ...[TODO] +% sizeref: ...[NA] +% sizemode: ...[NA] +% colorscale: ...[NA] +% cauto: ...[NA] +% cmin: ...[NA] +% cmax: ...[NA] +% outliercolor: ...[NA] +% maxdisplayed: ...[NA] + +% MARKER LINE: +% color: ...[DONE] +% width: ...[DONE] +% dash: ...[NA] +% opacity: ...[TODO] +% shape: ...[NA] +% smoothing: ...[NA] +% outliercolor: ...[NA] +% outlierwidth: ...[NA] + +%-------------------------------------------------------------------------% + +%-AXIS INDEX-% +axIndex = obj.getAxisIndex(obj.State.Plot(histIndex).AssociatedAxis); + +%-HIST DATA STRUCTURE- % +hist_data = get(obj.State.Plot(histIndex).Handle); + +%-------------------------------------------------------------------------% + +%-barpolar type-% +obj.data{histIndex}.type = 'barpolar'; + +%-------------------------------------------------------------------------% + +%-barpolar data-% +binedges = rad2deg(hist_data.BinEdges); +obj.data{histIndex}.theta = binedges(1:end-1) + 0.5*diff(binedges); +obj.data{histIndex}.width = diff(binedges); +obj.data{histIndex}.r = double(hist_data.BinCounts); + +%-------------------------------------------------------------------------% + +%-hist name-% +obj.data{histIndex}.name = hist_data.DisplayName; + +%-------------------------------------------------------------------------% + +%-layout barmode-% +obj.layout.barmode = 'group'; + +%-------------------------------------------------------------------------% + +%-hist line width-% +obj.data{histIndex}.marker.line.width = hist_data.LineWidth; + +%-------------------------------------------------------------------------% + +%-hist opacity-% +if ~ischar(hist_data.FaceAlpha) + obj.data{histIndex}.opacity = hist_data.FaceAlpha; +end + +%-------------------------------------------------------------------------% + +obj.data{histIndex}.marker = extractPatchFace(hist_data); + +%-------------------------------------------------------------------------% + +%-hist visible-% +obj.data{histIndex}.visible = strcmp(hist_data.Visible,'on'); + +%-------------------------------------------------------------------------% + +%-hist showlegend-% +leg = get(hist_data.Annotation); +legInfo = get(leg.LegendInformation); + +switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; +end + +obj.data{histIndex}.showlegend = showleg; + +%-------------------------------------------------------------------------% + +end From 4c004b3c2bcf7ae1892895014ddc40c0979efe8e Mon Sep 17 00:00:00 2001 From: Gilberto Galvis Date: Thu, 5 Aug 2021 18:00:20 -0400 Subject: [PATCH 2/3] fix issue #241: catch added to try in line 95 --- plotly/plotlyfig_aux/core/updateData.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 8a45a174..6d1ec703 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -126,6 +126,8 @@ ~strcmp(obj.data{dataIndex}.type,'box') obj.data{dataIndex}.y = get(obj.State.Plot(dataIndex).AssociatedAxis,'YTickLabel'); end +catch + % TODO to future end %-------------------------------------------------------------------------% From 8463ca83f91f3ce9a56f645ca5f45ba3fc45a1aa Mon Sep 17 00:00:00 2001 From: Gilberto Galvis Date: Thu, 5 Aug 2021 18:04:25 -0400 Subject: [PATCH 3/3] fix issue #241: catch added to try in line 95 --- plotly/plotlyfig_aux/core/updateData.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 6d1ec703..23d78825 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -127,7 +127,7 @@ obj.data{dataIndex}.y = get(obj.State.Plot(dataIndex).AssociatedAxis,'YTickLabel'); end catch - % TODO to future + % TODO to the future end %-------------------------------------------------------------------------%