Skip to content

Commit 662ab5d

Browse files
Test_plotlyfig: compare boxplot traces to the figure's lines
1 parent a5fa3aa commit 662ab5d

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

‎plotly/Test_plotlyfig.m‎

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,26 +1742,27 @@ function testBoxPlotData(tc)
17421742
p = plotlyfig(fig,"visible","off");
17431743

17441744
if is_octave()
1745-
tc.verifyNumElements(p.data, 6);
1746-
boxData = { ...
1747-
[0.6 0.6 0.6 1.4 1.4 1.4 1.4 1.4 0.6 0.6 0.6], ...
1748-
[0.4147 0.4394 0.4394 0.4394 0.4394 0.4147 0.0432756925294199 -0.0896 -0.0896 0.0432756925294199 0.4147]; ...
1749-
[1 1], [-0.874 -0.0896]; ...
1750-
[1 1], [1.0212 0.4394]; ...
1751-
[0.95 1.05], [-0.874 -0.874]; ...
1752-
[0.95 1.05], [1.0212 1.0212]; ...
1753-
[0.6 1.4], [0.4147 0.4147] ...
1754-
};
1755-
for i = 1:6
1745+
% compare against the boxplot's own line children in the
1746+
% order plotlyfig collects them (findobj order is reversed
1747+
% when the plots are collected); reading the figure keeps
1748+
% the test independent of the statistics package's
1749+
% quartile definition
1750+
ax = get(fig, 'currentaxes');
1751+
lines = findobj(ax, '-depth', 1, '-not', 'Type', 'Text', ...
1752+
'-not', 'Type', 'axes');
1753+
lines = lines(end:-1:1);
1754+
1755+
tc.verifyNumElements(p.data, numel(lines));
1756+
for i = 1:numel(lines)
17561757
tc.verifyEqualStructs(p.data{i}, struct( ...
17571758
"type", 'scatter', ...
17581759
"xaxis", 'x1', ...
17591760
"yaxis", 'y1', ...
17601761
"visible", true, ...
17611762
"name", '', ...
17621763
"mode", 'lines', ...
1763-
"x", boxData{i,1}, ...
1764-
"y", boxData{i,2}, ...
1764+
"x", get(lines(i), 'XData'), ...
1765+
"y", get(lines(i), 'YData'), ...
17651766
"line", struct( ...
17661767
"color", PlotlyTestCase.AnyColorString(), ...
17671768
"width", 0.5, ...

0 commit comments

Comments
 (0)