Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better error message for size #4844

Merged
merged 10 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/plot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions test/test_output.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,10 @@ 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 = ())
@test_throws ArgumentError savefig(plt, tempname())
BeastyBlacksmith marked this conversation as resolved.
Show resolved Hide resolved
end
Loading