Search code examples
rggplot2axistitle

How to change the axis of the plot titles in a ggplot in R


Does anybody know, how do I change the plot titles (annotated by the red arrow) to be horizontal in the following ggplot? And how do I move them to the left-hand side instead of having them on the right?

My code is as follows:

  coord_cartesian(ylim=c(min(mdf["value"]), max(mdf["value"]))) +
  theme(axis.text.y=element_blank(),
        axis.ticks.y=element_blank()) +
  xlab("Time (s)") +
  ylab("Channel signals") +
  geom_line() + 
  facet_grid(variable ~ .)

Thank you!!

enter image description here


Solution

  • To change the side, use

    facet_grid(variable ~ ., switch = "y")
    

    To rotate the labels, add the following to theme:

    strip.text.y.left = element_text(angle = 0)