0

Can someone identify that how can I place top and right axis labels for ggplot while using facet_grid?

Consider following code which is resulting plot given below. I want to place axis label "Days" and "Gender" for top and right axis. The one alternative is using labeller or 'levels` but it will change the top labels instead of having axis labels.

library(reshape2)
ggplot(tips, aes(total_bill, tip)) + 
  facet_grid(sex ~ day) + 
  geom_point() + 
  xlab("Total Bill") + 
  ylab("Tip")

enter image description here

mqpasta
  • 960
  • 3
  • 14
  • 38
  • I don't think you easily can... But `ggtitle` could be used for the top label. – Axeman Jun 13 '16 at 11:53
  • 1
    it' not perfect but you could try: b being the name of your plot; library(cowplot); ggdraw(b) + theme(plot.margin=unit(c(3,3,3,3),"mm")) + draw_label("Day", x = 0.5, y = 1, vjust = 1, hjust = 1, size = 14, fontface = 'bold') + draw_label("Gender", x = 1, y = 0.5, vjust = 1, hjust = 1, size = 14, fontface = 'bold', angle = 270) – MLavoie Jun 13 '16 at 14:23
  • 3
    Something like [this](http://stackoverflow.com/questions/36941197/overall-label-for-facets/37292665#37292665)? – Sandy Muspratt Jun 13 '16 at 21:05

0 Answers0