From 3106beaae2218bb6bdfc44b3cf22032a83056f79 Mon Sep 17 00:00:00 2001 From: Nicholas Bauer Date: Tue, 21 Jun 2022 23:03:54 -0400 Subject: [PATCH 1/4] Make layouts tolerant of fewer items. --- src/layouts.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/layouts.jl b/src/layouts.jl index 6f0548de5..62559427d 100644 --- a/src/layouts.jl +++ b/src/layouts.jl @@ -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 From afd9e575f892558f1c5037d49d85d1da044c5353 Mon Sep 17 00:00:00 2001 From: Nicholas Bauer Date: Wed, 22 Jun 2022 23:08:49 -0400 Subject: [PATCH 2/4] Add tests --- test/test_layouts.jl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/test_layouts.jl b/test/test_layouts.jl index d5d5cceec..08bdee9e7 100644 --- a/test/test_layouts.jl +++ b/test/test_layouts.jl @@ -33,6 +33,18 @@ end @test p[3][:framestyle] === :none end +@testset "Allowed subplot counts" begin + p = plot(plot(1:2), layout = grid(2, 2), grid = true) + @test length(p) == 1 + p = plot(plot(1:2), plot(1:2), layout = grid(2, 2), grid = true) + @test length(p) == 2 + p = plot(plot(1:2), plot(1:2), plot(1:2), layout = grid(2, 2), grid = true) + @test length(p) == 3 + p = plot(plot(1:2), plot(1:2), plot(1:2), plot(1:2), layout = grid(2, 2), grid = true) + @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), grid = true) +end + @testset "Coverage" begin p = plot((plot(i) for i in 1:4)..., layout = (2, 2)) From 165ca8db7d70840e88e4fdce5297213792cbb18a Mon Sep 17 00:00:00 2001 From: Nicholas Bauer Date: Wed, 22 Jun 2022 23:15:47 -0400 Subject: [PATCH 3/4] Remove grid kwarg --- test/test_layouts.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/test_layouts.jl b/test/test_layouts.jl index 08bdee9e7..4f2a09b57 100644 --- a/test/test_layouts.jl +++ b/test/test_layouts.jl @@ -34,15 +34,15 @@ end end @testset "Allowed subplot counts" begin - p = plot(plot(1:2), layout = grid(2, 2), grid = true) + 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), grid = true) + 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), grid = true) + p = plot(plot(1:2), plot(1:2), plot(1:2); layout = grid(2, 2)) @test length(p) == 3 - p = plot(plot(1:2), plot(1:2), plot(1:2), plot(1:2), layout = grid(2, 2), grid = true) + 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), grid = true) + @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 From 1c706e20a5da6eebc1ff38c6486574e0a0e80cd4 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Thu, 23 Jun 2022 15:33:22 +0200 Subject: [PATCH 4/4] format add `plot!` test --- test/test_layouts.jl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/test_layouts.jl b/test/test_layouts.jl index 4f2a09b57..151492dfd 100644 --- a/test/test_layouts.jl +++ b/test/test_layouts.jl @@ -40,9 +40,17 @@ end @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)) + @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