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

Skip to content

Commit b82e0b6

Browse files
fix issue #424
1 parent 7a6d265 commit b82e0b6

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
function obj = updateAlternativeBoxplot(obj, dataIndex)
2+
3+
%-------------------------------------------------------------------------%
4+
5+
%-INITIALIZATIONS-%
6+
7+
axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis);
8+
plotStructure = get(obj.State.Plot(dataIndex).Handle);
9+
plotData = plotStructure.Children;
10+
11+
nTraces = length(plotData);
12+
traceIndex = dataIndex;
13+
14+
%-------------------------------------------------------------------------%
15+
16+
%-update traces-%
17+
18+
for t = 1:nTraces
19+
20+
if t ~= 1
21+
obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1;
22+
traceIndex = obj.PlotOptions.nPlots;
23+
end
24+
25+
updateBoxplotLine(obj, axIndex, plotData(t), traceIndex);
26+
end
27+
28+
%-------------------------------------------------------------------------%
29+
end
30+
31+
function updateBoxplotLine(obj, axIndex, plotData, traceIndex)
32+
33+
%-------------------------------------------------------------------------%
34+
35+
%-INITIALIZATIONS-%
36+
37+
%-get axis info-%
38+
[xSource, ySource] = findSourceAxis(obj, axIndex);
39+
40+
%-get trade data-%
41+
xData = plotData.XData;
42+
yData = plotData.YData;
43+
44+
if isduration(xData) || isdatetime(xData), xData = datenum(xData); end
45+
if isduration(yData) || isdatetime(yData), yData = datenum(yData); end
46+
47+
if length(xData) < 2, xData = ones(1,2)*xData; end
48+
if length(yData) < 2, yData = ones(1,2)*yData; end
49+
50+
%-------------------------------------------------------------------------%
51+
52+
%-set trace-%
53+
obj.data{traceIndex}.type = 'scatter';
54+
obj.data{traceIndex}.mode = getScatterMode(plotData);
55+
obj.data{traceIndex}.visible = strcmp(plotData.Visible,'on');
56+
obj.data{traceIndex}.name = plotData.DisplayName;
57+
obj.data{traceIndex}.xaxis = sprintf('x%d', xSource);
58+
obj.data{traceIndex}.yaxis = sprintf('y%d', ySource);
59+
60+
%-------------------------------------------------------------------------%
61+
62+
%-set trace data-%
63+
obj.data{traceIndex}.x = xData;
64+
obj.data{traceIndex}.y = yData;
65+
66+
%-------------------------------------------------------------------------%
67+
68+
%-set marker properties-%
69+
obj.data{traceIndex}.marker = extractLineMarker(plotData);
70+
71+
%-set line properties-%
72+
obj.data{traceIndex}.line = extractLineLine(plotData);
73+
74+
%-------------------------------------------------------------------------%
75+
76+
%-legend-%
77+
leg = get(plotData.Annotation);
78+
legInfo = get(leg.LegendInformation);
79+
80+
switch legInfo.IconDisplayStyle
81+
case 'on'
82+
showLeg = true;
83+
case 'off'
84+
showLeg = false;
85+
end
86+
87+
obj.data{traceIndex}.showlegend = showLeg;
88+
89+
if isempty(obj.data{traceIndex}.name)
90+
obj.data{traceIndex}.showlegend = false;
91+
end
92+
93+
%-------------------------------------------------------------------------%
94+
end
95+
96+
function scatterMode = getScatterMode(plotData)
97+
98+
marker = plotData.Marker;
99+
lineStyle = plotData.LineStyle;
100+
101+
if ~strcmpi('none', marker) && ~strcmpi('none', lineStyle)
102+
scatterMode = 'lines+markers';
103+
104+
elseif ~strcmpi('none', marker)
105+
scatterMode = 'markers';
106+
107+
elseif ~strcmpi('none', lineStyle)
108+
scatterMode = 'lines';
109+
110+
else
111+
scatterMode = 'none';
112+
113+
end
114+
end

plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,15 @@
6060
bpnum = length(box_child)/bpcompnum;
6161
% check for assumed box structure
6262
if mod(length(box_child), bpcompnum)~=0
63+
updateAlternativeBoxplot(obj, boxIndex);
6364
return
6465
end
6566
else
6667
bpcompnum = 8;
6768
bpnum = length(box_child)/bpcompnum;
6869
% check for assumed box structure
6970
if mod(length(box_child),bpcompnum)~=0
71+
updateAlternativeBoxplot(obj, boxIndex);
7072
return
7173
end
7274
end

0 commit comments

Comments
 (0)