From 50f63cf1eb4dfc0246cfba43ded7c08af81f897b Mon Sep 17 00:00:00 2001 From: t-bltg <13423344+t-bltg@users.noreply.github.com> Date: Fri, 25 Jun 2021 15:40:49 +0200 Subject: [PATCH 1/3] Ignore :blank plots (#3585) --- src/layouts.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layouts.jl b/src/layouts.jl index ee984b35..a34c94a8 100644 --- a/src/layouts.jl +++ b/src/layouts.jl @@ -406,7 +406,7 @@ end # ---------------------------------------------------------------------- -calc_num_subplots(layout::AbstractLayout) = 1 +calc_num_subplots(layout::AbstractLayout) = get(layout.attr, :blank, false) ? 0 : 1 function calc_num_subplots(layout::GridLayout) tot = 0 for l in layout.grid From d657c0cb336037edf4f0fb8f18c92debdbc4b1d1 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Fri, 25 Jun 2021 16:57:10 +0200 Subject: [PATCH 2/3] 1.16.6 [skip ci] --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index ba785200..68e4e5bf 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Plots" uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" author = ["Tom Breloff (@tbreloff)"] -version = "1.16.5" +version = "1.16.6" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" From 7b0066c433fa528f77b7533d7f5d9e0eb12f009b Mon Sep 17 00:00:00 2001 From: t-bltg <13423344+t-bltg@users.noreply.github.com> Date: Fri, 25 Jun 2021 21:10:35 +0200 Subject: [PATCH 3/3] simplify major / minor grid segments (#3586) Co-authored-by: t-bltg --- src/axes.jl | 133 +++++++++++++++++++--------------------------------- 1 file changed, 49 insertions(+), 84 deletions(-) diff --git a/src/axes.jl b/src/axes.jl index 647c4b2c..c7837d8c 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -703,62 +703,47 @@ function axis_drawing_info(sp, letter) ) end end - if !(ax[:ticks] in (:none, nothing, false)) + if ax[:ticks] ∉ (:none, nothing, false) f = RecipesPipeline.scale_func(oax[:scale]) invf = RecipesPipeline.inverse_scale_func(oax[:scale]) - if ax[:tick_direction] !== :none - tick_start, tick_stop = if sp[:framestyle] == :origin - t = invf(f(0) + 0.012 * (f(oamax) - f(oamin))) - (-t, t) - else - ticks_in = ax[:tick_direction] == :out ? -1 : 1 - t = invf(f(oa1) + 0.012 * (f(oa2) - f(oa1)) * ticks_in) - (oa1, t) - end - end - for tick in ticks[1] - if ax[:showaxis] && ax[:tick_direction] !== :none - push!( - tick_segments, - reverse_if((tick, tick_start), isy), - reverse_if((tick, tick_stop), isy), - ) + add_major_or_minor_segments(ticks, grid, segments, factor, cond) = begin + if cond + tick_start, tick_stop = if sp[:framestyle] == :origin + t = invf(f(0) + factor * (f(oamax) - f(oamin))) + (-t, t) + else + ticks_in = ax[:tick_direction] == :out ? -1 : 1 + t = invf(f(oa1) + factor * (f(oa2) - f(oa1)) * ticks_in) + (oa1, t) + end end - if ax[:grid] - push!( - grid_segments, - reverse_if((tick, oamin), isy), - reverse_if((tick, oamax), isy), - ) - end - end - if !(ax[:minorticks] in (:none, nothing, false)) || ax[:minorgrid] - tick_start, tick_stop = if sp[:framestyle] == :origin - t = invf(f(0) + 0.006 * (f(oamax) - f(oamin))) - (-t, t) - else - t = invf(f(oa1) + 0.006 * (f(oa2) - f(oa1)) * ticks_in) - (oa1, t) - end - for tick in minor_ticks - if ax[:showaxis] + for tick in ticks + if ax[:showaxis] && cond push!( tick_segments, reverse_if((tick, tick_start), isy), reverse_if((tick, tick_stop), isy), ) end - if ax[:minorgrid] + if grid push!( - minorgrid_segments, + segments, reverse_if((tick, oamin), isy), reverse_if((tick, oamax), isy), ) end end end + + # add major grid segments + add_major_or_minor_segments(ticks[1], ax[:grid], grid_segments, 0.012, ax[:tick_direction] !== :none) + + # add minor grid segments + if ax[:minorticks] ∉ (:none, nothing, false) || ax[:minorgrid] + add_major_or_minor_segments(minor_ticks, ax[:minorgrid], minorgrid_segments, 0.006, true) + end end end @@ -841,74 +826,54 @@ function axis_drawing_info_3d(sp, letter) ) end end - # TODO this can be simplified, we do almost the same thing twice for grid and minorgrid - if !(ax[:ticks] in (:none, nothing, false)) + + if ax[:ticks] ∉ (:none, nothing, false) f = RecipesPipeline.scale_func(nax[:scale]) invf = RecipesPipeline.inverse_scale_func(nax[:scale]) - if ax[:tick_direction] !== :none - tick_start, tick_stop = if sp[:framestyle] == :origin - t = invf(f(0) + 0.012 * (f(namax) - f(namin))) - (-t, t) - else - ticks_in = ax[:tick_direction] == :out ? -1 : 1 - t = invf(f(na0) + 0.012 * (f(na1) - f(na0)) * ticks_in) - (na0, t) - end - end - ga0, ga1 = sp[:framestyle] in (:origin, :zerolines) ? (namin, namax) : (na0, na1) - for tick in ticks[1] - if ax[:showaxis] && ax[:tick_direction] !== :none - push!( - tick_segments, - sort_3d_axes(tick, tick_start, fa0, letter), - sort_3d_axes(tick, tick_stop, fa0, letter), - ) - end - if ax[:grid] - push!( - grid_segments, - sort_3d_axes(tick, ga0, fa0, letter), - sort_3d_axes(tick, ga1, fa0, letter), - ) - push!( - grid_segments, - sort_3d_axes(tick, ga1, fa0, letter), - sort_3d_axes(tick, ga1, fa1, letter), - ) - end - end - if !(ax[:minorticks] in (:none, nothing, false)) || ax[:minorgrid] - tick_start, tick_stop = if sp[:framestyle] == :origin - t = invf(f(0) + 0.006 * (f(namax) - f(namin))) - (-t, t) - else - t = invf(f(na0) + 0.006 * (f(na1) - f(na0)) * ticks_in) - (na0, t) + add_major_or_minor_segments(ticks, grid, segments, factor, cond) = begin + if cond + tick_start, tick_stop = if sp[:framestyle] == :origin + t = invf(f(0) + factor * (f(namax) - f(namin))) + (-t, t) + else + ticks_in = ax[:tick_direction] == :out ? -1 : 1 + t = invf(f(na0) + factor * (f(na1) - f(na0)) * ticks_in) + (na0, t) + end end - for tick in minor_ticks - if ax[:showaxis] && ax[:tick_direction] !== :none + + for tick in ticks + if ax[:showaxis] && cond push!( tick_segments, sort_3d_axes(tick, tick_start, fa0, letter), sort_3d_axes(tick, tick_stop, fa0, letter), ) end - if ax[:minorgrid] + if grid push!( - minorgrid_segments, + segments, sort_3d_axes(tick, ga0, fa0, letter), sort_3d_axes(tick, ga1, fa0, letter), ) push!( - minorgrid_segments, + segments, sort_3d_axes(tick, ga1, fa0, letter), sort_3d_axes(tick, ga1, fa1, letter), ) end end end + + # add major grid segments + add_major_or_minor_segments(ticks[1], ax[:grid], grid_segments, 0.012, ax[:tick_direction] !== :none) + + # add minor grid segments + if ax[:minorticks] ∉ (:none, nothing, false) || ax[:minorgrid] + add_major_or_minor_segments(minor_ticks, ax[:minorgrid], minorgrid_segments, 0.006, true) + end end end