diff --git a/src/plot.jl b/src/plot.jl index 30f982421..f16587489 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -231,7 +231,12 @@ end function prepare_output(plt::Plot) _before_layout_calcs(plt) - w, h = plt.attr[:size] + _wh = plt.attr[:size] + if length(_wh) != 2 + throw(ArgumentError("plot size must have length = 2, got size = $_wh")) + end + w, h = _wh + plt.layout.bbox = BoundingBox(0mm, 0mm, w * px, h * px) # One pass down and back up the tree to compute the minimum padding diff --git a/test/test_output.jl b/test/test_output.jl index 8a63849d8..12f3270a3 100644 --- a/test/test_output.jl +++ b/test/test_output.jl @@ -108,3 +108,12 @@ end Plots._show(io, MIME("text/html"), pl) end end + +@testset "size error handling" begin + plt = plot(size = ()) + @test_throws ArgumentError savefig(plt, tempname()) + plt = plot(size = (1)) + @test_throws ArgumentError savefig(plt, tempname()) + plt = plot(size = (1, 2, 3)) + @test_throws ArgumentError savefig(plt, tempname()) +end