Skip to content

Commit 04b2b2d

Browse files
Add tests for line and rectangle
1 parent b15f347 commit 04b2b2d

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

‎plotly/Test_plotlyfig.m‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3872,6 +3872,75 @@ function testImagescPlotData(tc)
38723872
end
38733873
try close(); catch; end
38743874
end
3875+
3876+
function testLinePrimitivePlotData(tc)
3877+
% the line() primitive becomes a single lines trace.
3878+
fig = figure("Visible","off");
3879+
x = [0 1 2];
3880+
y = [0 1 0];
3881+
line(x, y, "LineWidth", 2);
3882+
3883+
p = plotlyfig(fig,"visible","off");
3884+
3885+
tc.verifyNumElements(p.data, 1);
3886+
expected = struct( ...
3887+
"type", "scatter", ...
3888+
"xaxis", "x1", ...
3889+
"yaxis", "y1", ...
3890+
"visible", true, ...
3891+
"name", '', ...
3892+
"mode", 'lines', ...
3893+
"x", x, ...
3894+
"y", y, ...
3895+
"line", struct( ...
3896+
"color", PlotlyTestCase.AnyColorString(), ...
3897+
"width", 2, ...
3898+
"dash", "solid" ...
3899+
), ...
3900+
"marker", struct( ...
3901+
"size", 3.6, ...
3902+
"line", struct( ...
3903+
"width", 2 ...
3904+
), ...
3905+
"color", PlotlyTestCase.AnyColorString() ...
3906+
), ...
3907+
"showlegend", false ...
3908+
);
3909+
tc.verifyEqualStructs(p.data{1}, expected, 'AbsTol', 1e-15);
3910+
try close(); catch; end
3911+
end
3912+
3913+
function testRectanglePlotData(tc)
3914+
% rectangle() becomes a single closed-loop lines trace.
3915+
fig = figure("Visible","off");
3916+
x = [0 0 2 2 0];
3917+
y = [0 3 3 0 0];
3918+
rectangle("Position", [0 0 2 3], "FaceColor", "r");
3919+
3920+
p = plotlyfig(fig,"visible","off");
3921+
3922+
tc.verifyNumElements(p.data, 1);
3923+
expected = struct( ...
3924+
"type", "scatter", ...
3925+
"xaxis", "x1", ...
3926+
"yaxis", "y1", ...
3927+
"x", x, ...
3928+
"y", y, ...
3929+
"name", '', ...
3930+
"mode", 'lines', ...
3931+
"visible", true, ...
3932+
"fill", "tonexty", ...
3933+
"line", struct( ...
3934+
"color", PlotlyTestCase.AnyColorString(), ...
3935+
"width", 0.5, ...
3936+
"dash", "solid" ...
3937+
), ...
3938+
"fillcolor", PlotlyTestCase.AnyColorString(), ...
3939+
"showlegend", false ...
3940+
);
3941+
tc.verifyEqualStructs(p.data{1}, expected, 'AbsTol', 1e-15);
3942+
try close(); catch; end
3943+
end
38753944
end
38763945

38773946
methods (Static)

0 commit comments

Comments
 (0)