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

Skip to content

Commit 8662d33

Browse files
Add stacked plot test
1 parent 49def3a commit 8662d33

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

plotly/Test_plotlyfig.m

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,66 @@ function testVerticalConstantLineWithLabel(tc)
12431243
tc.verifyTrue(any(cellfun(@(ann) ann.xanchor == alignment, p.layout.annotations)));
12441244
end
12451245

1246+
function testStackedPlotData(tc)
1247+
fig = figure("Visible","off");
1248+
x = 1:5;
1249+
a = cos(x);
1250+
b = exp(x);
1251+
dt = datetime(2010,1,1) + years(x);
1252+
tb = table(dt',a',b',VariableNames=["date" "a" "b"]);
1253+
stackedplot(tb);
1254+
1255+
p = plotlyfig(fig,"visible","off");
1256+
1257+
tc.verifyNumElements(p.data, 3);
1258+
tc.verifyEqual(p.data{1}, struct( ...
1259+
"type", 'scatter', ...
1260+
"visible", true, ...
1261+
"name", 'date', ...
1262+
"xaxis", 'x1', ...
1263+
"yaxis", 'y1', ...
1264+
"x", x, ...
1265+
"y", b', ...
1266+
"mode", 'lines', ...
1267+
"line", struct( ...
1268+
"color", "rgb(0,114,189)", ...
1269+
"width", 0.5, ...
1270+
"dash", 'solid' ...
1271+
), ...
1272+
"showlegend", false ...
1273+
));
1274+
tc.verifyEqual(p.data{2}, struct( ...
1275+
"type", 'scatter', ...
1276+
"visible", true, ...
1277+
"name", 'a', ...
1278+
"xaxis", 'x1', ...
1279+
"yaxis", 'y2', ...
1280+
"x", x, ...
1281+
"y", a', ...
1282+
"mode", 'lines', ...
1283+
"line", struct( ...
1284+
"color", "rgb(0,114,189)", ...
1285+
"width", 0.5, ...
1286+
"dash", 'solid' ...
1287+
) ...
1288+
));
1289+
tc.verifyEqual(p.data{3}, struct( ...
1290+
"type", 'scatter', ...
1291+
"visible", true, ...
1292+
"name", 'b', ...
1293+
"xaxis", 'x1', ...
1294+
"yaxis", 'y3', ...
1295+
"x", x, ...
1296+
"y", dt', ...
1297+
"mode", 'lines', ...
1298+
"line", struct( ...
1299+
"color", "rgb(0,114,189)", ...
1300+
"width", 0.5, ...
1301+
"dash", 'solid' ...
1302+
) ...
1303+
));
1304+
end
1305+
12461306
function testDoubleYAxisAreaPlotData(tc)
12471307
fig = figure("Visible","off");
12481308
x = linspace(0,10);

0 commit comments

Comments
 (0)