astrsk
astrsk

Reputation: 395

R: placing x ticks under facet panel in ggplot2

In a faceted plot from ggplot2 package it is possible to change the position of tick marks by the functions like scale_x_continuous(position="top"). However, if tick marks are to be placed on top, they appear above faceting panels, as here:

library(ggplot2)
ggplot(mpg, aes(displ, cty)) + geom_point() + 
facet_grid(. ~ cyl) +coord_flip() +
scale_y_continuous(position="right")

enter image description here

Is it possible to place individual tick marks scales under the denotations of facets?

Upvotes: 1

Views: 288

Answers (1)

Prradep
Prradep

Reputation: 5716

How about pushing the facet panel to the bottom?

library(ggplot2)
ggplot(mpg, aes(displ, cty)) + geom_point() + 
    facet_grid(. ~ cyl, switch='x') +coord_flip() +
    scale_y_continuous(position="right")

enter image description here

Upvotes: 1

Related Questions