From f64c0a09203c91b6d04a74f79e6582f74d8ab181 Mon Sep 17 00:00:00 2001 From: dd0 Date: Tue, 18 Jun 2024 17:52:09 +0100 Subject: [PATCH] GR: Draw all gridlines before axis Separates grid drawing from the remainder of gr_draw_axis, so that all gridlines are drawn below the axis. Previously, y-axis gridlines were drawn after the x-axis and could overlap it. Fixes issue #4202 for GR. --- src/backends/gr.jl | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 896e978fb..15e14adfb 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -1407,26 +1407,52 @@ function gr_draw_axes(sp, vp) x_bg, y_bg = RecipesPipeline.unzip(GR.wc3towc.(area_x, area_y, area_z)) GR.fillarea(x_bg, y_bg) + foreach(letter -> gr_draw_axis_minorgrid_3d(sp, letter, vp), (:x, :y, :z)) + foreach(letter -> gr_draw_axis_grid_3d(sp, letter, vp), (:x, :y, :z)) foreach(letter -> gr_draw_axis_3d(sp, letter, vp), (:x, :y, :z)) elseif ispolar(sp) r = gr_set_viewport_polar(vp) # rmin, rmax = GR.adjustrange(ignorenan_minimum(r), ignorenan_maximum(r)) rmin, rmax = axis_limits(sp, :y) gr_polaraxes(rmin, rmax, sp) - elseif sp[:framestyle] !== :none + elseif sp[:framestyle] ≢ :none + foreach(letter -> gr_draw_axis_minorgrid(sp, letter, vp), (:x, :y)) + foreach(letter -> gr_draw_axis_grid(sp, letter, vp), (:x, :y)) foreach(letter -> gr_draw_axis(sp, letter, vp), (:x, :y)) end GR.settransparency(1.0) nothing end +function gr_draw_axis_minorgrid_3d(sp, letter, vp) + ax = axis_drawing_info_3d(sp, letter) + axis = sp[get_attr_symbol(letter, :axis)] + gr_draw_minorgrid(sp, axis, ax.minorgrid_segments, gr_polyline3d) +end + +function gr_draw_axis_grid_3d(sp, letter, vp) + ax = axis_drawing_info_3d(sp, letter) + axis = sp[get_attr_symbol(letter, :axis)] + gr_draw_grid(sp, axis, ax.grid_segments, gr_polyline3d) +end + +function gr_draw_axis_minorgrid(sp, letter, vp) + ax = axis_drawing_info(sp, letter) + axis = sp[get_attr_symbol(letter, :axis)] + gr_draw_minorgrid(sp, axis, ax.minorgrid_segments) +end + +function gr_draw_axis_grid(sp, letter, vp) + ax = axis_drawing_info(sp, letter) + axis = sp[get_attr_symbol(letter, :axis)] + gr_draw_grid(sp, axis, ax.grid_segments) +end + function gr_draw_axis(sp, letter, vp) ax = axis_drawing_info(sp, letter) axis = sp[get_attr_symbol(letter, :axis)] # draw segments - gr_draw_grid(sp, axis, ax.grid_segments) - gr_draw_minorgrid(sp, axis, ax.minorgrid_segments) gr_draw_spine(sp, axis, ax.segments) gr_draw_border(sp, axis, ax.border_segments) gr_draw_ticks(sp, axis, ax.tick_segments) @@ -1442,8 +1468,6 @@ function gr_draw_axis_3d(sp, letter, vp) axis = sp[get_attr_symbol(letter, :axis)] # draw segments - gr_draw_grid(sp, axis, ax.grid_segments, gr_polyline3d) - gr_draw_minorgrid(sp, axis, ax.minorgrid_segments, gr_polyline3d) gr_draw_spine(sp, axis, ax.segments, gr_polyline3d) gr_draw_border(sp, axis, ax.border_segments, gr_polyline3d) gr_draw_ticks(sp, axis, ax.tick_segments, gr_polyline3d)