Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 228174b

Browse files
Refactor updateHistogramPolar
1 parent d142141 commit 228174b

File tree

3 files changed

+18
-28
lines changed

3 files changed

+18
-28
lines changed

plotly/Test_plotlyfig.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ function testPolarHistogramPlotData(tc)
325325

326326
tc.verifyNumElements(p.data, 1);
327327
tc.verifyEqual(p.data{1}, struct( ...
328-
"type", 'barpolar', ...
328+
"type", "barpolar", ...
329329
"r", [1 6 3 0], ...
330330
"width", [22.5 22.5 22.5 22.5], ...
331331
"theta", [11.25 33.75 56.25 78.75], ...

plotly/plotlyfig_aux/core/updateData.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
updateCategoricalHistogram(obj, dataIndex);
6767
case "histogram"
6868
if obj.State.Plot(dataIndex).AssociatedAxis.Type == "polaraxes"
69-
updateHistogramPolar(obj, dataIndex);
69+
obj.data{dataIndex} = updateHistogramPolar(obj, dataIndex);
7070
else
7171
updateHistogram(obj, dataIndex);
7272
end

plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function obj = updateHistogramPolar(obj,histIndex)
1+
function data = updateHistogramPolar(obj,histIndex)
22
% x:...[DONE]
33
% y:...[DONE]
44
% histnorm:...[DONE]
@@ -45,40 +45,30 @@
4545
% outliercolor: ...[NA]
4646
% outlierwidth: ...[NA]
4747

48-
%-HIST DATA STRUCTURE- %
4948
hist_data = obj.State.Plot(histIndex).Handle;
5049

51-
%-barpolar type-%
52-
obj.data{histIndex}.type = 'barpolar';
50+
data.type = "barpolar";
5351

54-
%-barpolar data-%
5552
binedges = rad2deg(hist_data.BinEdges);
56-
obj.data{histIndex}.theta = binedges(1:end-1) + 0.5*diff(binedges);
57-
obj.data{histIndex}.width = diff(binedges);
58-
obj.data{histIndex}.r = double(hist_data.BinCounts);
53+
data.theta = binedges(1:end-1) + 0.5*diff(binedges);
54+
data.width = diff(binedges);
55+
data.r = double(hist_data.BinCounts);
5956

60-
obj.data{histIndex}.name = hist_data.DisplayName;
61-
obj.layout.barmode = 'group';
62-
obj.data{histIndex}.marker.line.width = hist_data.LineWidth;
57+
data.name = hist_data.DisplayName;
58+
obj.layout.barmode = "group";
59+
data.marker.line.width = hist_data.LineWidth;
6360

64-
%-hist opacity-%
6561
if ~ischar(hist_data.FaceAlpha)
66-
obj.data{histIndex}.opacity = hist_data.FaceAlpha;
62+
data.opacity = hist_data.FaceAlpha;
6763
end
6864

69-
obj.data{histIndex}.marker = extractPatchFace(hist_data);
70-
obj.data{histIndex}.visible = strcmp(hist_data.Visible,'on');
65+
data.marker = extractPatchFace(hist_data);
66+
data.visible = hist_data.Visible == "on";
7167

72-
%-hist showlegend-%
73-
leg = hist_data.Annotation;
74-
legInfo = leg.LegendInformation;
75-
76-
switch legInfo.IconDisplayStyle
77-
case 'on'
78-
showleg = true;
79-
case 'off'
80-
showleg = false;
68+
switch hist_data.Annotation.LegendInformation.IconDisplayStyle
69+
case "on"
70+
data.showlegend = true;
71+
case "off"
72+
data.showlegend = false;
8173
end
82-
83-
obj.data{histIndex}.showlegend = showleg;
8474
end

0 commit comments

Comments
 (0)