Skip to content

Commit c5990d3

Browse files
committed
adjust axis
1 parent 5e0473d commit c5990d3

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

R/coord-radial.R

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,36 @@ CoordRadial <- ggproto("CoordRadial", Coord,
359359
if (!isFALSE(self$r_axis_inside)) {
360360
return(list(left = zeroGrob(), right = zeroGrob()))
361361
}
362-
CoordCartesian$render_axis_v(panel_params, theme)
362+
axis <- CoordCartesian$render_axis_v(panel_params, theme)
363+
364+
# align the axis with the panel area
365+
panel_margin <- panel_params$panel_margin
366+
vp <- viewport(height = unit(1, "npc") - panel_margin * 2L)
367+
lapply(axis, function(g) {
368+
if (is.null(g$vp)) {
369+
editGrob(g, vp = vp)
370+
} else {
371+
editGrob(g, vp = vpStack(vp, g$vp))
372+
}
373+
})
363374
},
364375

365376
render_axis_h = function(self, panel_params, theme) {
366377
if (!isFALSE(self$r_axis_inside)) {
367378
return(list(top = zeroGrob(), bottom = zeroGrob()))
368379
}
369-
CoordCartesian$render_axis_h(panel_params, theme)
380+
axis <- CoordCartesian$render_axis_h(panel_params, theme)
381+
382+
# align the axis with the panel area
383+
panel_margin <- panel_params$panel_margin
384+
vp <- viewport(width = unit(1, "npc") - panel_margin * 2L)
385+
lapply(axis, function(g) {
386+
if (is.null(g$vp)) {
387+
editGrob(g, vp = vp)
388+
} else {
389+
editGrob(g, vp = vpStack(vp, g$vp))
390+
}
391+
})
370392
},
371393

372394
render_bg = function(self, panel_params, theme) {

0 commit comments

Comments
 (0)