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

Skip to content

Commit 8a89239

Browse files
Merge pull request #463 from plotly/fix_issue_423
fix issue #423
2 parents 1af323c + 40ca123 commit 8a89239

File tree

2 files changed

+107
-8
lines changed

2 files changed

+107
-8
lines changed

plotly/plotlyfig_aux/core/updateData.m

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
updatePColor(obj, dataIndex);
1313
elseif ismember('contour3', lower(obj.PlotOptions.TreatAs))
1414
updateContour3(obj, dataIndex);
15-
elseif ismember('compass', lower(obj.PlotOptions.TreatAs))
16-
updateLineseries(obj, dataIndex);
1715
elseif ismember('ezpolar', lower(obj.PlotOptions.TreatAs))
1816
updateLineseries(obj, dataIndex);
1917
elseif ismember('polarhistogram', lower(obj.PlotOptions.TreatAs))
@@ -32,16 +30,11 @@
3230
updateSurfc(obj, dataIndex);
3331
elseif ismember('surfl', lower(obj.PlotOptions.TreatAs))
3432
updateSurfl(obj, dataIndex);
35-
36-
% this one will be revomed
37-
% elseif strcmpi(obj.PlotOptions.TreatAs, 'streamtube')
38-
% updateStreamtube(obj, dataIndex);
39-
% end
4033

4134
%-update plot based on plot call class-%
4235

4336
else
44-
37+
4538
switch lower(obj.State.Plot(dataIndex).Class)
4639

4740
%--SPIDER PLOT -> SPECIAL CASE--%

plotly/plotlyfig_aux/handlegraphics/updateLineseries.m

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ function updateLineseries(obj, plotIndex)
5252
%-set trace-%
5353
if isPolar
5454
obj.data{plotIndex}.type = 'scatterpolar';
55+
updateDefaultPolaraxes(obj, plotIndex)
56+
obj.data{plotIndex}.subplot = sprintf('polar%d', xSource+1);
5557

5658
elseif ~isPlot3D
5759
obj.data{plotIndex}.type = 'scatter';
@@ -74,6 +76,7 @@ function updateLineseries(obj, plotIndex)
7476
if isPolar
7577
obj.data{plotIndex}.r = rData;
7678
obj.data{plotIndex}.theta = thetaData;
79+
7780
else
7881
obj.data{plotIndex}.x = xData;
7982
obj.data{plotIndex}.y = yData;
@@ -88,6 +91,9 @@ function updateLineseries(obj, plotIndex)
8891

8992
%-set trace line-%
9093
obj.data{plotIndex}.line = extractLineLine(plotData);
94+
if isPolar
95+
obj.data{plotIndex}.line.width = obj.data{plotIndex}.line.width * 1.5;
96+
end
9197

9298
%-set trace marker-%
9399
obj.data{plotIndex}.marker = extractLineMarker(plotData);
@@ -248,5 +254,105 @@ function updateScene(obj, dataIndex)
248254
%-SET SCENE TO LAYOUT-%
249255
obj.layout = setfield(obj.layout, sprintf('scene%d', xSource), scene);
250256

257+
%-------------------------------------------------------------------------%
258+
end
259+
260+
function updateDefaultPolaraxes(obj, plotIndex)
261+
262+
%-------------------------------------------------------------------------%
263+
264+
%-INITIALIZATIONS-%
265+
axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis);
266+
[xSource, ysource] = findSourceAxis(obj, axIndex);
267+
plotData = get(obj.State.Plot(plotIndex).Handle);
268+
axisData = get(plotData.Parent);
269+
270+
thetaAxis = axisData.XAxis;
271+
rAxis = axisData.YAxis;
272+
273+
%-------------------------------------------------------------------------%
274+
275+
%-set domain plot-%
276+
xo = axisData.Position(1);
277+
yo = axisData.Position(2);
278+
w = axisData.Position(3);
279+
h = axisData.Position(4);
280+
281+
polarAxis.domain.x = min([xo xo + w], 1);
282+
polarAxis.domain.y = min([yo yo + h], 1);
283+
284+
tickValues = rAxis.TickValues;
285+
tickValues = tickValues(find(tickValues==0) + 1 : end);
286+
287+
%-------------------------------------------------------------------------%
288+
289+
%-SET ANGULAR AXIS-%
290+
291+
gridColor = getStringColor(255*axisData.GridColor, axisData.GridAlpha);
292+
gridWidth = axisData.LineWidth;
293+
294+
polarAxis.angularaxis.ticklen = 0;
295+
polarAxis.angularaxis.autorange = true;
296+
polarAxis.angularaxis.linecolor = gridColor;
297+
polarAxis.angularaxis.gridwidth = gridWidth;
298+
polarAxis.angularaxis.gridcolor = gridColor;
299+
polarAxis.angularaxis.rotation = -axisData.View(1);
300+
301+
%-axis tick-%
302+
polarAxis.angularaxis.showticklabels = true;
303+
polarAxis.angularaxis.nticks = 16;
304+
polarAxis.angularaxis.tickfont.size = thetaAxis.FontSize;
305+
polarAxis.angularaxis.tickfont.color = getStringColor(...
306+
255*thetaAxis.Color);
307+
polarAxis.angularaxis.tickfont.family = matlab2plotlyfont(...
308+
thetaAxis.FontName);
309+
310+
%-axis label-%
311+
thetaLabel = thetaAxis.Label;
312+
313+
polarAxis.angularaxis.title.text = thetaLabel.String;
314+
polarAxis.radialaxis.title.font.size = thetaLabel.FontSize;
315+
polarAxis.radialaxis.title.font.color = getStringColor(...
316+
255*thetaLabel.Color);
317+
polarAxis.radialaxis.title.font.family = matlab2plotlyfont(...
318+
thetaLabel.FontName);
319+
320+
%-------------------------------------------------------------------------%
321+
322+
%-SET RADIAL AXIS-%
323+
324+
polarAxis.radialaxis.ticklen = 0;
325+
polarAxis.radialaxis.range = [0, tickValues(end)];
326+
polarAxis.radialaxis.showline = false;
327+
328+
polarAxis.radialaxis.angle = 80;
329+
polarAxis.radialaxis.tickangle = 80;
330+
331+
polarAxis.radialaxis.gridwidth = gridWidth;
332+
polarAxis.radialaxis.gridcolor = gridColor;
333+
334+
%-axis tick-%
335+
polarAxis.radialaxis.showticklabels = true;
336+
polarAxis.radialaxis.tickvals = tickValues;
337+
polarAxis.radialaxis.tickfont.size = rAxis.FontSize;
338+
polarAxis.radialaxis.tickfont.color = getStringColor(255*rAxis.Color);
339+
polarAxis.radialaxis.tickfont.family = matlab2plotlyfont(...
340+
rAxis.FontName);
341+
342+
%-axis label-%
343+
rLabel = rAxis.Label;
344+
345+
polarAxis.radialaxis.title.text = rLabel.String;
346+
polarAxis.radialaxis.title.font.size = rLabel.FontSize;
347+
polarAxis.radialaxis.title.font.color = getStringColor(255*rLabel.Color);
348+
polarAxis.radialaxis.title.font.family = matlab2plotlyfont(...
349+
rLabel.FontName);
350+
351+
%-------------------------------------------------------------------------%
352+
353+
%-set Polar Axes to layout-%
354+
obj.layout = setfield(obj.layout, sprintf('polar%d', xSource+1), ...
355+
polarAxis);
356+
251357
%-------------------------------------------------------------------------%
252358
end

0 commit comments

Comments
 (0)