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

Skip to content

Commit 7face21

Browse files
fix issue #427 V2
1 parent 565d8a0 commit 7face21

File tree

3 files changed

+38
-87
lines changed

3 files changed

+38
-87
lines changed

plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,39 @@
11
function updateGeoPlot(obj,geoIndex)
22

3-
%-AXIS INDEX-%
4-
axIndex = obj.getAxisIndex(obj.State.Plot(geoIndex).AssociatedAxis);
3+
%-----------------------------------------------------------------------------%
4+
5+
%-INTIALIZATIONS-%
56

6-
%-GET STRUCTURES-%
7+
axIndex = obj.getAxisIndex(obj.State.Plot(geoIndex).AssociatedAxis);
78
geoData = get(obj.State.Plot(geoIndex).Handle);
89
axisData = geoData.Parent;
9-
figureData = get(obj.State.Figure.Handle);
10-
11-
%-CHECK FOR MULTIPLE AXES-%
12-
[xsource, ysource] = findSourceAxis(obj,axIndex);
13-
14-
%-ASSOCIATE GEO-AXES LAYOUT-%
15-
if strcmpi(obj.PlotOptions.geoRenderType, 'geo')
16-
obj.data{geoIndex}.geo = sprintf('geo%d', xsource+1);
17-
elseif strcmpi(obj.PlotOptions.geoRenderType, 'mapbox')
18-
obj.data{geoIndex}.subplot = sprintf('mapbox%d', xsource+1);
19-
end
10+
[xSource, ~] = findSourceAxis(obj,axIndex);
2011

2112
%-------------------------------------------------------------------------%
2213

23-
%-set scattergeo type-%
14+
%-set trace-%
2415
if strcmpi(obj.PlotOptions.geoRenderType, 'geo')
16+
obj.data{geoIndex}.geo = sprintf('geo%d', xSource+1);
2517
obj.data{geoIndex}.type = 'scattergeo';
2618

27-
%-set scattermapbox type-%
2819
elseif strcmpi(obj.PlotOptions.geoRenderType, 'mapbox')
20+
obj.data{geoIndex}.subplot = sprintf('mapbox%d', xSource+1);
2921
obj.data{geoIndex}.type = 'scattermapbox';
3022
end
3123

32-
%-------------------------------------------------------------------------%
33-
34-
%-set scattergeo mode-%
3524
obj.data{geoIndex}.mode = 'lines+markers';
3625

3726
%-------------------------------------------------------------------------%
3827

39-
%-set plot data-%
28+
%-set trace data-%
4029
obj.data{geoIndex}.lat = geoData.LatitudeData;
4130
obj.data{geoIndex}.lon = geoData.LongitudeData;
4231

4332
%-------------------------------------------------------------------------%
4433

45-
%-get marker setting-%
34+
%-set trace's marker and line-%
4635
[marker, linee] = extractGeoLinePlusMarker(geoData, axisData);
4736

48-
%-------------------------------------------------------------------------%
49-
5037
%-corrections-%
5138
if strcmpi(geoData.Marker, 'none')
5239
obj.data{geoIndex}.mode = 'lines';
@@ -61,14 +48,7 @@ function updateGeoPlot(obj,geoIndex)
6148
end
6249
end
6350

64-
%-------------------------------------------------------------------------%
65-
66-
%-set marker field-%
6751
obj.data{geoIndex}.marker = marker;
68-
69-
%-------------------------------------------------------------------------%
70-
71-
%-set line field-%
7252
obj.data{geoIndex}.line = linee;
7353

7454
%-------------------------------------------------------------------------%

plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,37 @@
11
function updateGeoScatter(obj,geoIndex)
22

3-
%-AXIS INDEX-%
4-
axIndex = obj.getAxisIndex(obj.State.Plot(geoIndex).AssociatedAxis);
3+
%-----------------------------------------------------------------------------%
4+
5+
%-INTIALIZATIONS-%
56

6-
%-GET STRUCTURES-%
7+
axIndex = obj.getAxisIndex(obj.State.Plot(geoIndex).AssociatedAxis);
78
geoData = get(obj.State.Plot(geoIndex).Handle);
89
axisData = geoData.Parent;
9-
figureData = get(obj.State.Figure.Handle);
10-
11-
%-CHECK FOR MULTIPLE AXES-%
12-
[xsource, ysource] = findSourceAxis(obj,axIndex);
13-
14-
%-ASSOCIATE GEO-AXES LAYOUT-%
15-
if strcmpi(obj.PlotOptions.geoRenderType, 'geo')
16-
obj.data{geoIndex}.geo = sprintf('geo%d', xsource+1);
17-
elseif strcmpi(obj.PlotOptions.geoRenderType, 'mapbox')
18-
obj.data{geoIndex}.subplot = sprintf('mapbox%d', xsource+1);
19-
end
10+
[xSource, ~] = findSourceAxis(obj,axIndex);
2011

2112
%-------------------------------------------------------------------------%
2213

23-
%-set scattergeo type-%
14+
%-set trace-%
2415
if strcmpi(obj.PlotOptions.geoRenderType, 'geo')
16+
obj.data{geoIndex}.geo = sprintf('geo%d', xSource+1);
2517
obj.data{geoIndex}.type = 'scattergeo';
2618

27-
%-set scattermapbox type-%
2819
elseif strcmpi(obj.PlotOptions.geoRenderType, 'mapbox')
20+
obj.data{geoIndex}.subplot = sprintf('mapbox%d', xSource+1);
2921
obj.data{geoIndex}.type = 'scattermapbox';
3022
end
3123

32-
%-------------------------------------------------------------------------%
33-
34-
%-set scattergeo mode-%
3524
obj.data{geoIndex}.mode = 'markers+text';
3625

3726
%-------------------------------------------------------------------------%
3827

39-
%-set plot data-%
28+
%-set trace data-%
4029
obj.data{geoIndex}.lat = geoData.LatitudeData;
4130
obj.data{geoIndex}.lon = geoData.LongitudeData;
4231

4332
%-------------------------------------------------------------------------%
4433

45-
%-get marker setting-%
34+
%-set trace marker-%
4635
marker = extractGeoMarker(geoData, axisData);
4736

4837
if strcmpi(obj.PlotOptions.geoRenderType, 'mapbox')
@@ -54,9 +43,6 @@ function updateGeoScatter(obj,geoIndex)
5443
end
5544
end
5645

57-
%-------------------------------------------------------------------------%
58-
59-
%-set marker field-%
6046
obj.data{geoIndex}.marker = marker;
6147

6248
%-------------------------------------------------------------------------%

plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
function updateGeobubble(obj,geoIndex)
22

3-
%-AXIS INDEX-%
4-
axIndex = obj.getAxisIndex(obj.State.Plot(geoIndex).AssociatedAxis);
5-
6-
%-GET STRUCTURES-%
7-
geoData = get(obj.State.Plot(geoIndex).Handle);
3+
%-----------------------------------------------------------------------------%
84

9-
%-CHECK FOR MULTIPLE AXES-%
10-
[xsource, ysource] = findSourceAxis(obj,axIndex);
5+
%-INTIALIZATIONS-%
116

12-
%-----------------------------------------------------------------------------%
7+
axIndex = obj.getAxisIndex(obj.State.Plot(geoIndex).AssociatedAxis);
8+
geoData = get(obj.State.Plot(geoIndex).Handle);
9+
[xSource, ~] = findSourceAxis(obj,axIndex);
1310

14-
%-PASE DATA-%
11+
%-get trace data-%
1512
bubbleRange = geoData.BubbleWidthRange;
1613
allLats = geoData.LatitudeData;
1714
allLons = geoData.LongitudeData;
1815
allSizes = rescale(geoData.SizeData, bubbleRange(1), bubbleRange(2));
16+
colorMap = geoData.BubbleColorList;
17+
nColors = size(colorMap, 1);
1918

2019
if ~isempty(geoData.ColorData)
2120
allNames = geoData.ColorData;
@@ -53,7 +52,7 @@ function updateGeobubble(obj,geoIndex)
5352

5453
%=============================================================================%
5554
%
56-
%-SETTING GEOBBUBLE PLOT-%
55+
%-SET TRACES-%
5756
%
5857
%=============================================================================%
5958

@@ -71,50 +70,36 @@ function updateGeobubble(obj,geoIndex)
7170

7271
%-------------------------------------------------------------------------%
7372

74-
%-set scattergeo type-%
73+
%-set current trace-%
7574
if strcmpi(obj.PlotOptions.geoRenderType, 'geo')
7675
obj.data{p}.type = 'scattergeo';
76+
obj.data{p}.geo = sprintf('geo%d', xSource+1);
7777

78-
%-set scattermapbox type-%
7978
elseif strcmpi(obj.PlotOptions.geoRenderType, 'mapbox')
8079
obj.data{p}.type = 'scattermapbox';
80+
obj.data{p}.subplot = sprintf('mapbox%d', xSource+1);
8181
end
8282

83-
%-------------------------------------------------------------------------%
84-
85-
%-set scattergeo mode-%
8683
obj.data{p}.mode = 'markers';
8784

8885
%-------------------------------------------------------------------------%
8986

90-
%-set plot data-%
87+
%-set current trace data-%
9188
obj.data{p}.lat = lat{g};
9289
obj.data{p}.lon = lon{g};
9390

9491
%-------------------------------------------------------------------------%
9592

96-
%-get marker setting-%
93+
%-set trace marker-%
9794
marker = struct();
9895
marker.size = sData{g}*1.25;
99-
marker.color = sprintf('rgb(%f,%f,%f)', 255*geoData.BubbleColorList(g ,:));
96+
marker.color = getStringColor(255*colorMap(mod(g-1, nColors)+1, :));
10097
marker.line.color = 'rgb(255, 255, 255)';
10198

102-
%-------------------------------------------------------------------------%
103-
104-
%-set marker field-%
10599
obj.data{p}.marker = marker;
106100

107101
%-------------------------------------------------------------------------%
108102

109-
%-ASSOCIATE GEO-AXES LAYOUT-%
110-
if strcmpi(obj.PlotOptions.geoRenderType, 'geo')
111-
obj.data{p}.geo = sprintf('geo%d', xsource+1);
112-
elseif strcmpi(obj.PlotOptions.geoRenderType, 'mapbox')
113-
obj.data{p}.subplot = sprintf('mapbox%d', xsource+1);
114-
end
115-
116-
%-------------------------------------------------------------------------%
117-
118103
%-legend-%
119104
if byGroups
120105
obj.data{p}.name = group{g};
@@ -128,7 +113,7 @@ function updateGeobubble(obj,geoIndex)
128113

129114
%=============================================================================%
130115
%
131-
%-SETTING LAYOUT-%
116+
%-UPDATE GEO AXES-%
132117
%
133118
%=============================================================================%
134119

@@ -225,9 +210,9 @@ function updateGeobubble(obj,geoIndex)
225210

226211
%-set geo geoaxes to layout-%
227212
if strcmpi(obj.PlotOptions.geoRenderType, 'geo')
228-
obj.layout = setfield(obj.layout, sprintf('geo%d', xsource+1), geoaxes);
213+
obj.layout = setfield(obj.layout, sprintf('geo%d', xSource+1), geoaxes);
229214
elseif strcmpi(obj.PlotOptions.geoRenderType, 'mapbox')
230-
obj.layout = setfield(obj.layout, sprintf('mapbox%d', xsource+1), geoaxes);
215+
obj.layout = setfield(obj.layout, sprintf('mapbox%d', xSource+1), geoaxes);
231216
end
232217

233218
%-----------------------------------------------------------------------------%

0 commit comments

Comments
 (0)