Skip to content

Commit

Permalink
GR: Draw all gridlines before axis (v2) (#4960)
Browse files Browse the repository at this point in the history
* 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.

* Added qualified PlotsBase names missing from v1 port
  • Loading branch information
dd0 authored Jul 13, 2024
1 parent f32247a commit 617b8aa
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions PlotsBase/ext/GRExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1585,26 +1585,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
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 = PlotsBase.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 = PlotsBase.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 = PlotsBase.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 = PlotsBase.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 = PlotsBase.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)
Expand All @@ -1620,8 +1646,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)
Expand Down

0 comments on commit 617b8aa

Please sign in to comment.