Skip to content

Commit

Permalink
simplified draw_axis for ggplot 3.5 for subguides
Browse files Browse the repository at this point in the history
  • Loading branch information
mjskay committed Feb 22, 2024
1 parent b26f041 commit ed9ea60
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions R/subguide.R
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,27 @@ get_subguide_axis_position = function(side, position, orientation) {
stop0("Unknown orientation: ", deparse0(orientation)) # nocov
)
}

# modified version of ggplot2:::draw_axis for use by subguide_axis
draw_axis = function(
break_positions, break_labels, aes, opp, axis_position, theme,
check.overlap = FALSE, angle = NULL, n.dodge = 1
) {
guide = guide_axis(
check.overlap = check.overlap,
angle = angle,
n.dodge = n.dodge,
position = axis_position
)
params = guide$params
params$key = data_frame(
!!aes := break_positions,
.value = break_positions,
.label = break_labels
)
params$decor = data_frame0(
!!aes := c(0, 1),
!!opp := if (axis_position %in% c("top", "right")) 0 else 1
)
guide$draw(theme, params = params)
}

0 comments on commit ed9ea60

Please sign in to comment.