Skip to content

Commit ffbc5ff

Browse files
committed
Little better, but not fixed yet
1 parent a3985bf commit ffbc5ff

File tree

2 files changed

+140
-120
lines changed

2 files changed

+140
-120
lines changed

plotly/plotlyfig_aux/handlegraphics/updateBubblecloud.m

Lines changed: 38 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,32 @@ function updateBubblecloud(obj,bcIndex)
1313
% eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']);
1414
% eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']);
1515

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>';
16+
% obj.layout.xaxis.side = 'bottom';
17+
obj.layout.xaxis1.showline = false;
18+
obj.layout.xaxis1.zeroline = false;
19+
% obj.layout.xaxis.autorange = false;
20+
% % obj.layout.xaxis.linecolor='rgb(0,0,0)';
21+
% obj.layout.xaxis.showgrid = true;
22+
% obj.layout.xaxis.linewidth = 1;
23+
% obj.layout.xaxis.type = 'linear';
24+
% obj.layout.xaxis.anchor = 'y1';
25+
obj.layout.xaxis1.mirror = true;
26+
%
27+
%
28+
% obj.layout.yaxis.side = 'left';
29+
obj.layout.yaxis1.showline = false;
30+
obj.layout.yaxis1.zeroline = false;
31+
% obj.layout.yaxis.autorange = false;
32+
% % obj.layout.yaxis.linecolor='rgb(0,0,0)';
33+
% obj.layout.yaxis.showgrid = true;
34+
% obj.layout.yaxis.linewidth = 1;
35+
% obj.layout.yaxis.type = 'linear';
36+
% obj.layout.yaxis.anchor = 'x1';
37+
obj.layout.yaxis1.mirror = true;
38+
39+
obj.layout.title.text='<b><b></b></b>';
3640
obj.layout.margin.t=80;
41+
obj.layout.annotations{1}.text='';
3742

3843
%-------------------------------------------------------------------------%
3944

@@ -87,18 +92,20 @@ function updateBubblecloud(obj,bcIndex)
8792
xy = matlab.graphics.internal.layoutBubbleCloud(sortedradii,ar);
8893
fac=2*ar;
8994
rads = 2*sortedradii * (840 / ( fac*max(xy(1,:)) - fac*min(xy(1,:))));
90-
xy = matlab.graphics.internal.layoutBubbleCloud(rads,ar);
95+
% xy = matlab.graphics.internal.layoutBubbleCloud(rads,ar);
9196

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,:))];
97+
obj.layout.xaxis1.range=[fac*min(xy(1,:)), fac*max(xy(1,:))];
98+
obj.layout.yaxis1.range=[(fac/ar)*min(xy(2,:)), (fac/ar)*max(xy(2,:))];
9499

95-
rads = 2*rads * (840 / ( fac*max(xy(1,:)) - fac*min(xy(1,:))));
100+
% rads = 2*rads * (840 / ( fac*max(xy(1,:)) - fac*min(xy(1,:))));
96101

97102
%-------------------------------------------------------------------------%
98103

99104
labels = bcData.LabelData(RadiusIndex);
100105
obj.data{bcIndex}.text = arrayfun(@(x) {char(x)}, labels);
101106

107+
obj.data{bcIndex}.textfont = matlab2plotlyfont(bcData.FontName);
108+
102109
%-------------------------------------------------------------------------%
103110

104111
% obj.data{bcIndex}.hoverinfo = '';
@@ -167,35 +174,24 @@ function updateBubblecloud(obj,bcIndex)
167174

168175
%---------------------------------------------------------------------%
169176

170-
%-bc marker-%
171-
childmarker = extractScatterMarker(bcData);
172-
173-
%---------------------------------------------------------------------%
174-
175177
%-line color-%
176178
if length(bcData) > 1
177179
obj.data{bcIndex}.marker.line.color{m} = childmarker.line.color{1};
178180
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
181+
col=uint8(bcData.EdgeColor*255);
182+
obj.data{bcIndex}.marker.line.color = sprintf('rgb(%i,%i,%i)',col);
184183
end
185184

186185
%---------------------------------------------------------------------%
187186

188187
%-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
188+
col=uint8(bcData.ColorOrder(1,:)*255);
189+
obj.data{bcIndex}.marker.color = sprintf('rgb(%i,%i,%i)',col);
194190

195191
%---------------------------------------------------------------------%
196192

197193
%-sizeref-%
198-
obj.data{bcIndex}.marker.sizeref = 1; %2*max(bcData.SizeData)/(33^2);
194+
obj.data{bcIndex}.marker.sizeref = 1;
199195

200196
%---------------------------------------------------------------------%
201197

@@ -205,28 +201,17 @@ function updateBubblecloud(obj,bcIndex)
205201
%---------------------------------------------------------------------%
206202

207203
%-symbol-%
208-
obj.data{bcIndex}.marker.symbol = childmarker.symbol;
204+
obj.data{bcIndex}.marker.symbol = 'circle';
209205

210206
%---------------------------------------------------------------------%
211207

212208
%-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
209+
obj.data{bcIndex}.marker.size = rads;
222210

223211
%---------------------------------------------------------------------%
224212

225213
%-line width-%
226-
227214
obj.data{bcIndex}.marker.line.width = 1.5;
228-
% obj.data{bcIndex}.marker.line.width(1:length(childmarker.line.color)) = childmarker.line.width;
229-
230215

231216
%---------------------------------------------------------------------%
232217

plotly/plotlyfig_aux/helpers/extractAxisData.m

Lines changed: 102 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,15 @@
77
%-------------------------------------------------------------------------%
88

99
%-axis-side-%
10-
axis.side = eval(['axis_data.' axisName 'AxisLocation;']);
11-
10+
try
11+
axis.side = eval(['axis_data.' axisName 'AxisLocation;']);
12+
catch
13+
if axisName == 'X'
14+
axis.side = 'bottom';
15+
elseif axisName == 'Y'
16+
axis.side = 'left';
17+
end
18+
end
1219
%-------------------------------------------------------------------------%
1320

1421
%-axis zeroline-%
@@ -36,16 +43,23 @@
3643

3744
%-------------------------------------------------------------------------%
3845

39-
ticklength = min(obj.PlotlyDefaults.MaxTickLength,...
40-
max(axis_data.TickLength(1)*axis_data.Position(3)*obj.layout.width,...
41-
axis_data.TickLength(1)*axis_data.Position(4)*obj.layout.height));
46+
try
47+
ticklength = min(obj.PlotlyDefaults.MaxTickLength,...
48+
max(axis_data.TickLength(1)*axis_data.Position(3)*obj.layout.width,...
49+
axis_data.TickLength(1)*axis_data.Position(4)*obj.layout.height));
4250
%-axis ticklen-%
43-
axis.ticklen = ticklength;
44-
51+
axis.ticklen = ticklength;
52+
catch
53+
axis.ticklen = 0;
54+
end
4555
%-------------------------------------------------------------------------%
4656

47-
col = eval(['255*axis_data.' axisName 'Color;']);
48-
axiscol = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')'];
57+
try
58+
col = eval(['255*axis_data.' axisName 'Color;']);
59+
catch
60+
col = [0,0,0];
61+
end
62+
axiscol = sprintf('rgb(%i,%i,%i)',col);
4963

5064
%-axis linecolor-%
5165
axis.linecolor = axiscol;
@@ -57,29 +71,38 @@
5771
axis.gridcolor = axiscol;
5872

5973
%-------------------------------------------------------------------------%
60-
61-
if strcmp(axis_data.XGrid, 'on') || strcmp(axis_data.XMinorGrid, 'on')
62-
%-axis show grid-%
63-
axis.showgrid = true;
64-
else
65-
axis.showgrid = false;
74+
try
75+
if strcmp(axis_data.XGrid, 'on') || strcmp(axis_data.XMinorGrid, 'on')
76+
%-axis show grid-%
77+
axis.showgrid = true;
78+
else
79+
axis.showgrid = false;
80+
end
81+
catch
82+
axis.showgrid = false;
6683
end
67-
6884
%-------------------------------------------------------------------------%
6985

70-
grid = eval(['axis_data.' axisName 'Grid;']);
71-
minorGrid = eval(['axis_data.' axisName 'MinorGrid;']);
86+
try
87+
grid = eval(['axis_data.' axisName 'Grid;']);
88+
minorGrid = eval(['axis_data.' axisName 'MinorGrid;']);
7289

73-
if strcmp(grid, 'on') || strcmp(minorGrid, 'on')
74-
%-axis show grid-%
75-
axis.showgrid = true;
76-
else
90+
if strcmp(grid, 'on') || strcmp(minorGrid, 'on')
91+
%-axis show grid-%
92+
axis.showgrid = true;
93+
else
94+
axis.showgrid = false;
95+
end
96+
catch
7797
axis.showgrid = false;
7898
end
7999

80100
%-------------------------------------------------------------------------%
81-
82-
linewidth = max(1,axis_data.LineWidth*obj.PlotlyDefaults.AxisLineIncreaseFactor);
101+
try
102+
linewidth = max(1,axis_data.LineWidth*obj.PlotlyDefaults.AxisLineIncreaseFactor);
103+
catch
104+
linewidth = 0;
105+
end
83106

84107
%-axis line width-%
85108
axis.linewidth = linewidth;
@@ -91,12 +114,21 @@
91114
%-------------------------------------------------------------------------%
92115

93116
%-axis type-%
94-
axis.type = eval(['axis_data.' axisName 'Scale']);
117+
try
118+
axis.type = eval(['axis_data.' axisName 'Scale']);
119+
catch
120+
axis.type = 'linear';
121+
end
95122

96123
%-------------------------------------------------------------------------%
97124

98125
%-axis showtick labels / ticks-%
99-
tick = eval(['axis_data.' axisName 'Tick']);
126+
try
127+
tick = eval(['axis_data.' axisName 'Tick']);
128+
catch
129+
tick=[];
130+
end
131+
100132
if isempty(tick)
101133

102134
%-axis ticks-%
@@ -107,13 +139,16 @@
107139
axis.autorange = true;
108140

109141
%---------------------------------------------------------------------%
110-
111-
switch axis_data.Box
112-
case 'on'
113-
%-axis mirror-%
114-
axis.mirror = true;
115-
case 'off'
116-
axis.mirror = false;
142+
try
143+
switch axis_data.Box
144+
case 'on'
145+
%-axis mirror-%
146+
axis.mirror = true;
147+
case 'off'
148+
axis.mirror = false;
149+
end
150+
catch
151+
axis.mirror = true;
117152
end
118153

119154
%---------------------------------------------------------------------%
@@ -295,50 +330,56 @@
295330
end
296331

297332
%-------------------------------------------------------------------------%
298-
299-
Dir = eval(['axis_data.' axisName 'Dir;']);
333+
try
334+
Dir = eval(['axis_data.' axisName 'Dir;']);
335+
catch
336+
Dir = '';
337+
end
300338
if strcmp(Dir,'reverse')
301339
axis.range = [axis.range(2) axis.range(1)];
302340
end
303341

304342
%-------------------------------LABELS------------------------------------%
343+
try
344+
label = eval(['axis_data.' axisName 'Label;']);
345+
catch
346+
label=[];
347+
end
348+
if ~isempty(label)
349+
label_data = get(label);
305350

306-
label = eval(['axis_data.' axisName 'Label;']);
307-
308-
label_data = get(label);
309-
310-
%STANDARDIZE UNITS
311-
fontunits = get(label,'FontUnits');
312-
set(label,'FontUnits','points');
351+
%STANDARDIZE UNITS
352+
fontunits = get(label,'FontUnits');
353+
set(label,'FontUnits','points');
313354

314-
%-------------------------------------------------------------------------%
355+
%-------------------------------------------------------------------------%
315356

316-
%-title-%
317-
if ~isempty(label_data.String)
318-
axis.title = parseString(label_data.String,label_data.Interpreter);
319-
end
320-
321-
%-------------------------------------------------------------------------%
357+
%-title-%
358+
if ~isempty(label_data.String)
359+
axis.title = parseString(label_data.String,label_data.Interpreter);
360+
end
322361

323-
%-axis title font color-%
324-
col = 255*label_data.Color;
325-
axis.titlefont.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')'];
362+
%-------------------------------------------------------------------------%
326363

327-
%-------------------------------------------------------------------------%
364+
%-axis title font color-%
365+
col = 255*label_data.Color;
366+
axis.titlefont.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')'];
328367

329-
%-axis title font size-%
330-
axis.titlefont.size = label_data.FontSize;
368+
%-------------------------------------------------------------------------%
331369

332-
%-------------------------------------------------------------------------%
370+
%-axis title font size-%
371+
axis.titlefont.size = label_data.FontSize;
333372

334-
%-axis title font family-%
335-
axis.titlefont.family = matlab2plotlyfont(label_data.FontName);
373+
%-------------------------------------------------------------------------%
336374

337-
%-------------------------------------------------------------------------%
375+
%-axis title font family-%
376+
axis.titlefont.family = matlab2plotlyfont(label_data.FontName);
338377

339-
%REVERT UNITS
340-
set(label,'FontUnits',fontunits);
378+
%-------------------------------------------------------------------------%
341379

380+
%REVERT UNITS
381+
set(label,'FontUnits',fontunits);
382+
end
342383
%-------------------------------------------------------------------------%
343384

344385
if strcmp(axis_data.Visible,'on')
@@ -351,12 +392,6 @@
351392
axis.showticklabels = false;
352393
%-axis ticks-%
353394
axis.ticks = '';
354-
%-axis showline-%
355-
axis.showline = false;
356-
%-axis showticklabels-%
357-
axis.showticklabels = false;
358-
%-axis ticks-%
359-
axis.ticks = '';
360395
end
361396

362397
%-------------------------------------------------------------------------%

0 commit comments

Comments
 (0)