Skip to content

Commit 3d937ba

Browse files
Refactor extractScatterMarker.m
1 parent 41d462d commit 3d937ba

File tree

2 files changed

+56
-64
lines changed

2 files changed

+56
-64
lines changed

plotly/Test_plotlyfig.m

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,13 @@ function testScatterPlotData(tc)
204204
y = y, ...
205205
marker = struct( ...
206206
sizeref = 1, ...
207-
sizemode = 'area', ...
207+
sizemode = "area", ...
208208
size = 36 * ones(size(x)), ...
209209
line = struct( ...
210210
width = 0.7500, ...
211211
color = "rgb(0,114,189)" ...
212212
), ...
213-
symbol = 'circle', ...
213+
symbol = "circle", ...
214214
color = "rgba(0,0,0,0)", ...
215215
opacity = 1 ...
216216
), ...
@@ -238,13 +238,13 @@ function testSingleScatterPlotData(tc)
238238
y = {{y}}, ...
239239
marker = struct( ...
240240
sizeref = 1, ...
241-
sizemode = 'area', ...
241+
sizemode = "area", ...
242242
size = {{36}}, ...
243243
line = struct( ...
244244
width = 0.7500, ...
245245
color = "rgb(0,114,189)" ...
246246
), ...
247-
symbol = 'circle', ...
247+
symbol = "circle", ...
248248
color = "rgba(0,0,0,0)", ...
249249
opacity = 1 ...
250250
), ...
@@ -274,13 +274,13 @@ function testScatter3DPlotData(tc)
274274
z = z, ...
275275
marker = struct( ...
276276
sizeref = 1, ...
277-
sizemode = 'area', ...
277+
sizemode = "area", ...
278278
size = 72 * ones(size(x)), ...
279279
line = struct( ...
280280
width = 0.7500, ...
281281
color = "rgb(0,114,189)" ...
282282
), ...
283-
symbol = 'circle', ...
283+
symbol = "circle", ...
284284
color = "rgba(0,0,0,0)", ...
285285
opacity = 1 ...
286286
), ...
@@ -347,13 +347,13 @@ function testPolarScatterData(tc)
347347
mode = 'markers', ...
348348
marker = struct( ...
349349
sizeref = 1, ...
350-
sizemode = 'area', ...
350+
sizemode = "area", ...
351351
size = [36 36 36 36 36 36 36 36], ...
352352
line = struct( ...
353353
width = 0.75, ...
354354
color = "rgb(0,114,189)" ...
355355
), ...
356-
symbol = 'circle', ...
356+
symbol = "circle", ...
357357
color = "rgba(0,0,0,0)", ...
358358
opacity = 1 ...
359359
), ...

plotly/plotlyfig_aux/helpers/extractScatterMarker.m

Lines changed: 48 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,115 +8,107 @@
88
% SCATTERGROUP. %
99
% %
1010
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
11-
12-
%-INITIALIZATIONS-%
1311
axisData = ancestor(plotData.Parent, ["Axes" "PolarAxes"]);
14-
figureData = ancestor(plotData.Parent, 'figure');
12+
figureData = ancestor(plotData.Parent, "figure");
1513

1614
marker = struct();
1715
marker.sizeref = 1;
18-
marker.sizemode = 'area';
16+
marker.sizemode = "area";
1917
marker.size = getMarkerSize(plotData);
2018
marker.line.width = 1.5*plotData.LineWidth;
2119

2220
filledMarkerSet = {'o', 'square', 's', 'diamond', 'd', 'v', '^', ...
2321
'<', '>', 'hexagram', 'pentagram'};
2422
filledMarker = ismember(plotData.Marker, filledMarkerSet);
2523

26-
%-get marker symbol-%
27-
if ~strcmp(plotData.Marker,'none')
24+
if plotData.Marker ~= "none"
2825
switch plotData.Marker
29-
case '.'
30-
markerSymbol = 'circle';
26+
case "."
27+
markerSymbol = "circle";
3128
marker.size = 0.1*marker.size;
32-
case 'o'
33-
markerSymbol = 'circle';
34-
case 'x'
35-
markerSymbol = 'x-thin-open';
36-
case '+'
37-
markerSymbol = 'cross-thin-open';
38-
case '*'
39-
markerSymbol = 'asterisk-open';
40-
case {'s','square'}
41-
markerSymbol = 'square';
42-
case {'d','diamond'}
43-
markerSymbol = 'diamond';
44-
case 'v'
45-
markerSymbol = 'triangle-down';
46-
case '^'
47-
markerSymbol = 'triangle-up';
48-
case '<'
49-
markerSymbol = 'triangle-left';
50-
case '>'
51-
markerSymbol = 'triangle-right';
52-
case {'p','pentagram'}
53-
markerSymbol = 'star';
54-
case {'h','hexagram'}
55-
markerSymbol = 'hexagram';
29+
case "o"
30+
markerSymbol = "circle";
31+
case "x"
32+
markerSymbol = "x-thin-open";
33+
case "+"
34+
markerSymbol = "cross-thin-open";
35+
case "*"
36+
markerSymbol = "asterisk-open";
37+
case {"s","square"}
38+
markerSymbol = "square";
39+
case {"d","diamond"}
40+
markerSymbol = "diamond";
41+
case "v"
42+
markerSymbol = "triangle-down";
43+
case "^"
44+
markerSymbol = "triangle-up";
45+
case "<"
46+
markerSymbol = "triangle-left";
47+
case ">"
48+
markerSymbol = "triangle-right";
49+
case {"p","pentagram"}
50+
markerSymbol = "star";
51+
case {"h","hexagram"}
52+
markerSymbol = "hexagram";
5653
end
5754
marker.symbol = markerSymbol;
5855
end
5956

60-
%-marker fill-%
6157
markerFaceColor = plotData.MarkerFaceColor;
6258
markerFaceAlpha = plotData.MarkerFaceAlpha;
6359

6460
if filledMarker
65-
%-get face color-%
6661
if isnumeric(markerFaceColor)
6762
faceColor = getStringColor(round(255*markerFaceColor));
6863
else
6964
switch markerFaceColor
70-
case 'none'
65+
case "none"
7166
faceColor = "rgba(0,0,0,0)";
72-
case 'auto'
73-
if ~strcmp(axisData.Color,'none')
74-
faceColor = round(255*axisData.Color);
67+
case "auto"
68+
if axisData.Color ~= "none"
69+
faceColor = axisData.Color;
7570
else
76-
faceColor = round(255*figureData.Color);
71+
faceColor = figureData.Color;
7772
end
78-
faceColor = getStringColor(faceColor);
79-
case 'flat'
73+
faceColor = getStringColor(round(255*faceColor));
74+
case "flat"
8075
faceColor = getScatterFlatColor(plotData, axisData);
8176
end
8277
end
8378

84-
%-get face alpha-%
8579
if isnumeric(markerFaceAlpha)
8680
faceAlpha = markerFaceAlpha;
8781
else
8882
switch markerFaceColor
89-
case 'none'
83+
case "none"
9084
faceAlpha = 1;
91-
case 'flat'
85+
case "flat"
9286
aLim = axisData.ALim;
9387
faceAlpha = plotData.AlphaData;
9488
faceAlpha = rescaleData(faceAlpha, aLim);
9589
end
9690
end
97-
%-set marker fill-%
9891
marker.color = faceColor;
9992
marker.opacity = faceAlpha;
10093
end
10194

102-
%-marker line-%
10395
markerEdgeColor = plotData.MarkerEdgeColor;
10496
markerEdgeAlpha = plotData.MarkerEdgeAlpha;
10597

10698
if isnumeric(markerEdgeColor)
10799
lineColor = getStringColor(round(255*markerEdgeColor));
108100
else
109101
switch markerEdgeColor
110-
case 'none'
102+
case "none"
111103
lineColor = "rgba(0,0,0,0)";
112-
case 'auto'
113-
if ~strcmp(axisData.Color,'none')
114-
lineColor = round(255*axisData.Color);
104+
case "auto"
105+
if axisData.Color ~= "none"
106+
lineColor = axisData.Color;
115107
else
116-
lineColor = round(255*figureData.Color);
108+
lineColor = figureData.Color;
117109
end
118-
lineColor = getStringColor(lineColor, markerEdgeAlpha);
119-
case 'flat'
110+
lineColor = getStringColor(round(255*lineColor), markerEdgeAlpha);
111+
case "flat"
120112
lineColor = getScatterFlatColor(plotData, axisData);
121113
end
122114
end
@@ -125,13 +117,13 @@
125117
marker.line.color = lineColor;
126118
else
127119
marker.color = lineColor;
128-
if strcmp(plotData.Marker, '.')
120+
if plotData.Marker == "."
129121
marker.line.color = lineColor;
130122
end
131123
end
132124
end
133125

134-
function flatColor = getScatterFlatColor(plotData, axisData, opacity)
126+
function flatColor = getScatterFlatColor(plotData, axisData)
135127
cData = plotData.CData;
136128
colorMap = axisData.Colormap;
137129
cLim = axisData.CLim;
@@ -153,8 +145,8 @@
153145

154146
if size(numColor, 1) == 1
155147
flatColor = getStringColor(numColor);
156-
157148
else
149+
flatColor = cell(1, size(numColor, 1));
158150
for n = 1:size(numColor, 1)
159151
flatColor{n} = getStringColor(numColor(n, :));
160152
end

0 commit comments

Comments
 (0)