|
| 1 | +function updateBubblecloud(obj,bcIndex) |
| 2 | + |
| 3 | +%-AXIS INDEX-% |
| 4 | +axIndex = obj.getAxisIndex(obj.State.Plot(bcIndex).AssociatedAxis); |
| 5 | + |
| 6 | +%-BubbleCloud (bc) DATA STRUCTURE- % |
| 7 | +bcData = get(obj.State.Plot(bcIndex).Handle); |
| 8 | + |
| 9 | +%-CHECK FOR MULTIPLE AXES-% |
| 10 | +[xsource, ysource] = findSourceAxis(obj,axIndex); |
| 11 | + |
| 12 | +% %-AXIS DATA-% |
| 13 | +% eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); |
| 14 | +% eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); |
| 15 | + |
| 16 | +obj.layout.xaxis.side = 'bottom'; |
| 17 | +obj.layout.xaxis.zeroline = 0; |
| 18 | +obj.layout.xaxis.autorange = 0; |
| 19 | +obj.layout.xaxis.linecolor='rgb(38.25,38.25,38.25)'; |
| 20 | +obj.layout.xaxis.showgrid = 0; |
| 21 | +obj.layout.xaxis.linewidth = 1; |
| 22 | +obj.layout.xaxis.type = 'linear'; |
| 23 | +obj.layout.xaxis.showline = 0; |
| 24 | +obj.layout.xaxis.anchor = 'y1'; |
| 25 | + |
| 26 | +obj.layout.yaxis.side = 'left'; |
| 27 | +obj.layout.yaxis.zeroline = 0; |
| 28 | +obj.layout.yaxis.autorange = 0; |
| 29 | +obj.layout.yaxis.linecolor='rgb(38.25,38.25,38.25)'; |
| 30 | +obj.layout.yaxis.showgrid = 0; |
| 31 | +obj.layout.yaxis.linewidth = 1; |
| 32 | +obj.layout.yaxis.type = 'linear'; |
| 33 | +obj.layout.yaxis.showline = 0; |
| 34 | +obj.layout.yaxis.anchor = 'x1'; |
| 35 | +obj.layout.title='<b><b></b></b>'; |
| 36 | +obj.layout.margin.t=80; |
| 37 | + |
| 38 | +%-------------------------------------------------------------------------% |
| 39 | + |
| 40 | +%-bc xaxis-% |
| 41 | +obj.data{bcIndex}.xaxis = ['x' num2str(xsource)]; |
| 42 | + |
| 43 | +%-------------------------------------------------------------------------% |
| 44 | + |
| 45 | +%-bc yaxis-% |
| 46 | +obj.data{bcIndex}.yaxis = ['y' num2str(ysource)]; |
| 47 | + |
| 48 | +%-------------------------------------------------------------------------% |
| 49 | + |
| 50 | +%-bc type-% |
| 51 | +obj.data{bcIndex}.type = 'scatter'; |
| 52 | + |
| 53 | +%-------------------------------------------------------------------------% |
| 54 | + |
| 55 | +%-bc mode-% |
| 56 | +obj.data{bcIndex}.mode = 'markers+text'; |
| 57 | + |
| 58 | +%-------------------------------------------------------------------------% |
| 59 | + |
| 60 | +%-bc visible-% |
| 61 | +obj.data{bcIndex}.visible = strcmp(bcData.Visible,'on'); |
| 62 | + |
| 63 | +%-------------------------------------------------------------------------% |
| 64 | + |
| 65 | +%-bc name-% |
| 66 | +obj.data{bcIndex}.name = bcData.LegendTitle; |
| 67 | + |
| 68 | +%-------------------------------------------------------------------------% |
| 69 | + |
| 70 | +[sortedradii,sortind]=sort(sqrt(real(bcData.SizeData)),'descend'); |
| 71 | +validind=isfinite(sortedradii) & sortedradii>0; |
| 72 | +sortind=sortind(validind); |
| 73 | +sortedradii=sortedradii(validind); |
| 74 | + |
| 75 | +if bcData.MaxDisplayBubbles < numel(sortind) |
| 76 | + sortind=sortind(1:bcData.MaxDisplayBubbles); |
| 77 | + sortedradii=sortedradii(1:bcData.MaxDisplayBubbles); |
| 78 | +end |
| 79 | +RadiusIndex=sortind; |
| 80 | + |
| 81 | +% Normalize radii so that the largest bubble has a radius of 1 |
| 82 | +if ~isempty(sortedradii) |
| 83 | + sortedradii=sortedradii/max(sortedradii); |
| 84 | +end |
| 85 | + |
| 86 | +ar = 840/630; |
| 87 | +xy = matlab.graphics.internal.layoutBubbleCloud(sortedradii,ar); |
| 88 | +fac=2*ar; |
| 89 | +rads = 2*sortedradii * (840 / ( fac*max(xy(1,:)) - fac*min(xy(1,:)))); |
| 90 | +xy = matlab.graphics.internal.layoutBubbleCloud(rads,ar); |
| 91 | + |
| 92 | +obj.layout.xaxis.range=[fac*min(xy(1,:)), fac*max(xy(1,:))]; |
| 93 | +obj.layout.yaxis.range=[(fac/ar)*min(xy(2,:)), (fac/ar)*max(xy(2,:))]; |
| 94 | + |
| 95 | +rads = 2*rads * (840 / ( fac*max(xy(1,:)) - fac*min(xy(1,:)))); |
| 96 | + |
| 97 | +%-------------------------------------------------------------------------% |
| 98 | + |
| 99 | +labels = bcData.LabelData(RadiusIndex); |
| 100 | +obj.data{bcIndex}.text = arrayfun(@(x) {char(x)}, labels); |
| 101 | + |
| 102 | +%-------------------------------------------------------------------------% |
| 103 | + |
| 104 | +% obj.data{bcIndex}.hoverinfo = ''; |
| 105 | +obj.data{bcIndex}.hovertemplate = 'Size: %{hovertext}<br>Label: %{text}'; |
| 106 | +obj.data{bcIndex}.hovertext = arrayfun(@(x) {num2str(x)}, bcData.SizeData(RadiusIndex)); |
| 107 | + |
| 108 | +%-------------------------------------------------------------------------% |
| 109 | + |
| 110 | +%-bc x-% |
| 111 | +% if length(bcData) > 1 |
| 112 | +% obj.data{bcIndex}.x(m) = bcData(n).XData; |
| 113 | +% else |
| 114 | + obj.data{bcIndex}.x = xy(1,:); |
| 115 | +% end |
| 116 | + |
| 117 | +%---------------------------------------------------------------------% |
| 118 | + |
| 119 | +%-bc y-% |
| 120 | +% if length(bcData) > 1 |
| 121 | +% obj.data{bcIndex}.y(m) = bcData(n).YData; |
| 122 | +% else |
| 123 | + obj.data{bcIndex}.y = xy(2,:); |
| 124 | +% end |
| 125 | + |
| 126 | +%---------------------------------------------------------------------% |
| 127 | + |
| 128 | +%-bc z-% |
| 129 | +% if isHG2() |
| 130 | +% if isfield(bcData,'ZData') |
| 131 | +% if any(bcData.ZData) |
| 132 | +% if length(bcData) > 1 |
| 133 | +% obj.data{bcIndex}.z(m) = bcData(n).ZData; |
| 134 | +% else |
| 135 | +% obj.data{bcIndex}.z = bcData.ZData; |
| 136 | +% end |
| 137 | +% % overwrite type |
| 138 | +% obj.data{bcIndex}.type = 'scatter3d'; |
| 139 | +% end |
| 140 | +% end |
| 141 | +% end |
| 142 | + |
| 143 | +%---------------------------------------------------------------------% |
| 144 | + |
| 145 | +%-bc showlegend-% |
| 146 | +try |
| 147 | + leg = get(bcData.Annotation); |
| 148 | +catch |
| 149 | + leg=[]; |
| 150 | +end |
| 151 | +if ~isempty(leg) |
| 152 | + legInfo = get(leg.LegendInformation); |
| 153 | + |
| 154 | + switch legInfo.IconDisplayStyle |
| 155 | + case 'on' |
| 156 | + showleg = true; |
| 157 | + case 'off' |
| 158 | + showleg = false; |
| 159 | + end |
| 160 | +end |
| 161 | + |
| 162 | +if isfield(bcData,'ZData') |
| 163 | + if isempty(bcData.ZData) |
| 164 | + obj.data{bcIndex}.showlegend = showleg; |
| 165 | + end |
| 166 | +end |
| 167 | + |
| 168 | +%---------------------------------------------------------------------% |
| 169 | + |
| 170 | +%-bc marker-% |
| 171 | +childmarker = extractScatterMarker(bcData); |
| 172 | + |
| 173 | +%---------------------------------------------------------------------% |
| 174 | + |
| 175 | +%-line color-% |
| 176 | +if length(bcData) > 1 |
| 177 | + obj.data{bcIndex}.marker.line.color{m} = childmarker.line.color{1}; |
| 178 | +else |
| 179 | + if length(childmarker.line.color) > 3 |
| 180 | + obj.data{bcIndex}.marker.line.color = childmarker.line.color; |
| 181 | + else |
| 182 | + obj.data{bcIndex}.marker.line.color = childmarker.line.color{1}; |
| 183 | + end |
| 184 | +end |
| 185 | + |
| 186 | +%---------------------------------------------------------------------% |
| 187 | + |
| 188 | +%-marker color-% |
| 189 | +if length(bcData) > 1 |
| 190 | + obj.data{bcIndex}.marker.color{m} = childmarker.color{1}; |
| 191 | +else |
| 192 | + obj.data{bcIndex}.marker.color = childmarker.color; |
| 193 | +end |
| 194 | + |
| 195 | +%---------------------------------------------------------------------% |
| 196 | + |
| 197 | +%-sizeref-% |
| 198 | +obj.data{bcIndex}.marker.sizeref = 1; %2*max(bcData.SizeData)/(33^2); |
| 199 | + |
| 200 | +%---------------------------------------------------------------------% |
| 201 | + |
| 202 | +%-sizemode-% |
| 203 | +obj.data{bcIndex}.marker.sizemode = 'diameter'; |
| 204 | + |
| 205 | +%---------------------------------------------------------------------% |
| 206 | + |
| 207 | +%-symbol-% |
| 208 | +obj.data{bcIndex}.marker.symbol = childmarker.symbol; |
| 209 | + |
| 210 | +%---------------------------------------------------------------------% |
| 211 | + |
| 212 | +%-size-% |
| 213 | +% if length(bcData) > 1 |
| 214 | + obj.data{bcIndex}.marker.size = rads; %sort(bcData.sizeData,'descend'); |
| 215 | + |
| 216 | +%max(bcData.SizeData)*sortedradii; |
| 217 | + |
| 218 | + |
| 219 | +% else |
| 220 | +% obj.data{bcIndex}.marker.size = childmarker.size * 0.15; |
| 221 | +% end |
| 222 | + |
| 223 | +%---------------------------------------------------------------------% |
| 224 | + |
| 225 | +%-line width-% |
| 226 | + |
| 227 | +obj.data{bcIndex}.marker.line.width = 1.5; |
| 228 | +% obj.data{bcIndex}.marker.line.width(1:length(childmarker.line.color)) = childmarker.line.width; |
| 229 | + |
| 230 | + |
| 231 | +%---------------------------------------------------------------------% |
| 232 | + |
| 233 | +end |
| 234 | + |
0 commit comments