Skip to content

Axis text on both sides #195

Answered by teunbrand
saslaw asked this question in Q&A
Jun 18, 2025 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

You can add a secondary x-axis guide that should do the trick. Wouldn't even need ggh4x::facet_grid2() for this.

library(ggplot2)

ggplot(mpg, aes(displ, hwy)) +
  geom_point() +
  facet_grid(
    drv ~ .,
    scales = "free_y"
  ) +
  guides(x.sec = guide_axis(title = "displ"))

Created on 2025-06-18 with reprex v2.1.1

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@saslaw
Comment options

Answer selected by saslaw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants