Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions src/layouts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,9 @@ end

function layout_args(plotattributes::AKW, n_override::Integer)
layout, n = layout_args(n_override, get(plotattributes, :layout, n_override))
if n != n_override
if n < n_override
error(
"When doing layout, n ($n) != n_override ($(n_override)). You're probably trying to force existing plots into a layout that doesn't fit them.",
"When doing layout, n ($n) < n_override ($(n_override)). You're probably trying to force existing plots into a layout that doesn't fit them.",
)
end
layout, n
Expand Down
20 changes: 20 additions & 0 deletions test/test_layouts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,26 @@ end
@test p[3][:framestyle] === :none
end

@testset "Allowed subplot counts" begin
p = plot(plot(1:2); layout = grid(2, 2))
@test length(p) == 1
p = plot(plot(1:2), plot(1:2); layout = grid(2, 2))
@test length(p) == 2
p = plot(plot(1:2), plot(1:2), plot(1:2); layout = grid(2, 2))
@test length(p) == 3
@test length(plot!(p, plot(1:2))) == 4
p = plot(plot(1:2), plot(1:2), plot(1:2), plot(1:2); layout = grid(2, 2))
@test length(p) == 4
@test_throws ErrorException plot(
plot(1:2),
plot(1:2),
plot(1:2),
plot(1:2),
plot(1:2);
layout = grid(2, 2),
)
end

@testset "Coverage" begin
p = plot((plot(i) for i in 1:4)..., layout = (2, 2))

Expand Down