Skip to content

Commit 393beb6

Browse files
Fix polar scatter plot
1 parent 9b9d88f commit 393beb6

File tree

4 files changed

+43
-5
lines changed

4 files changed

+43
-5
lines changed

plotly/Test_plotlyfig.m

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,39 @@ function testSurfacePlotData(tc)
307307
), AbsTol=1e-15);
308308
end
309309

310+
function testPolarScatterData(tc)
311+
fig = figure("Visible","off");
312+
t = pi/4:pi/4:2*pi;
313+
r = [19 6 12 18 16 11 15 15];
314+
polarscatter(t,r)
315+
316+
p = plotlyfig(fig,"visible","off");
317+
318+
tc.verifyNumElements(p.data, 1);
319+
tc.verifyEqual(p.data{1}, struct( ...
320+
"subplot", 'polar2', ...
321+
"type", 'scatterpolar', ...
322+
"visible", true, ...
323+
"name", '', ...
324+
"r", r, ...
325+
"theta", rad2deg(t), ...
326+
"mode", 'markers', ...
327+
"marker", struct( ...
328+
"sizeref", 1, ...
329+
"sizemode", 'area', ...
330+
"size", [36 36 36 36 36 36 36 36], ...
331+
"line", struct( ...
332+
"width", 0.75, ...
333+
"color", "rgb(0,114,189)" ...
334+
), ...
335+
"symbol", 'circle', ...
336+
"color", "rgba(0,0,0,0)", ...
337+
"opacity", 1 ...
338+
), ...
339+
"showlegend", true ...
340+
), AbsTol=1e-15);
341+
end
342+
310343
function testPolarPlotData(tc)
311344
fig = figure("Visible","off");
312345
t = 0:0.01:2*pi;

plotly/plotlyfig_aux/core/updateData.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
case "quivergroup"
136136
updateQuivergroup(obj, dataIndex);
137137
case "scatter"
138-
if ismember("scatterpolar", lower(obj.PlotOptions.TreatAs))
138+
if obj.State.Plot(dataIndex).AssociatedAxis.Type == "polaraxes"
139139
updateScatterPolar(obj, dataIndex);
140140
elseif obj.PlotlyDefaults.isGeoaxis
141141
updateGeoScatter(obj, dataIndex);

plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function updateScatterPolar(obj, plotIndex)
3333

3434
obj.data{plotIndex}.marker = markerStruct;
3535

36-
if length(markerStruct.size) == 1
36+
if isscalar(markerStruct.size)
3737
obj.data{plotIndex}.marker.size = markerStruct.size * 0.2;
3838
end
3939

plotly/plotlyfig_aux/helpers/extractScatterMarker.m

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
1111

1212
%-INITIALIZATIONS-%
13-
axisData = ancestor(plotData.Parent, 'axes');
13+
axisData = ancestor(plotData.Parent, ["Axes" "PolarAxes"]);
1414
figureData = ancestor(plotData.Parent, 'figure');
1515

1616
marker = struct();
@@ -174,7 +174,12 @@
174174
function markerSize = getMarkerSize(plotData)
175175
markerSize = plotData.SizeData;
176176

177-
if length(markerSize) == 1
178-
markerSize = markerSize * ones(size(plotData.XData));
177+
if isscalar(markerSize)
178+
if ~isempty(plotData.XData)
179+
dataSize = size(plotData.XData);
180+
else
181+
dataSize = size(plotData.RData); % polar plot
182+
end
183+
markerSize = markerSize * ones(dataSize);
179184
end
180185
end

0 commit comments

Comments
 (0)