Skip to content

Commit 5cf6d96

Browse files
Merge pull request #256 from plotly/issue245
fix issue #245
2 parents 421d097 + 6cd8dae commit 5cf6d96

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

plotly/plotlyfig.m

+1
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,7 @@ function delete(obj)
898898
if ~( ...
899899
strcmpi(fieldname,'surface') || strcmpi(fieldname,'scatter3d') ...
900900
|| strcmpi(fieldname,'mesh3d') || strcmpi(fieldname,'bar') ...
901+
|| strcmpi(fieldname,'scatterpolar') ...
901902
)
902903
fprintf(['\nWhoops! ' exception.message(1:end-1) ' in ' fieldname '\n\n']);
903904
end

plotly/plotlyfig_aux/handlegraphics/updateLineseries.m

+28-2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ function updateLineseries(obj,plotIndex)
6565

6666
%-------------------------------------------------------------------------%
6767

68+
%-if compass or not-%
69+
iscompass = false;
70+
x = plot_data.XData;
71+
y = plot_data.YData;
72+
73+
if length(x)==5 && length(y)==5 && x(2)==x(4) && y(2)==y(4)
74+
iscompass = true;
75+
end
76+
77+
%-------------------------------------------------------------------------%
78+
6879
%-scatter xaxis-%
6980
obj.data{plotIndex}.xaxis = ['x' num2str(xsource)];
7081

@@ -78,6 +89,10 @@ function updateLineseries(obj,plotIndex)
7889
%-scatter type-%
7990
obj.data{plotIndex}.type = 'scatter';
8091

92+
if iscompass
93+
obj.data{plotIndex}.type = 'scatterpolar';
94+
end
95+
8196
%-------------------------------------------------------------------------%
8297

8398
%-scatter visible-%
@@ -86,12 +101,23 @@ function updateLineseries(obj,plotIndex)
86101
%-------------------------------------------------------------------------%
87102

88103
%-scatter x-%
89-
obj.data{plotIndex}.x = plot_data.XData;
104+
105+
if iscompass
106+
r = sqrt(x.^2 + y.^2);
107+
obj.data{plotIndex}.r = r;
108+
else
109+
obj.data{plotIndex}.x = x;
110+
end
90111

91112
%-------------------------------------------------------------------------%
92113

93114
%-scatter y-%
94-
obj.data{plotIndex}.y = plot_data.YData;
115+
if iscompass
116+
theta = atan2(x,y);
117+
obj.data{plotIndex}.theta = -(rad2deg(theta) - 90);
118+
else
119+
obj.data{plotIndex}.y = plot_data.YData;
120+
end
95121

96122
%-------------------------------------------------------------------------%
97123

0 commit comments

Comments
 (0)