This is a test version of Biostars. For the public version, visit https://www.biostars.org.
GGplot adding scales under specific graphs.

I am trying to create a visualisation of read-length distribution using ggplot2, but I have an awkward prime-number of samples ( 17 ), so I cannot get scales underneath each column.

Does anyone know how I would add x scales to the MS10134, MS10135, and MS10136 samples specifically.

If I change the facet_wrap to "free_x" I will get scales underneath each plot, which isn't what I want.

The code and a image of the plot are below.

plot

p = map_q %>% ggplot(aes(read_length,fill=name)) +
  geom_density() +
  facet_wrap(~name,ncol=4,nrow=5) +
  theme_bw() +
  theme(legend.position="none") +
  scale_x_continuous(breaks=pretty_breaks(10)) +
  xlab("Read Length") +
  ylab("Mapped read density") +
  ggtitle("Merged Read Length Distributions")

If it is not possible I can always revert to inkscape.

Thanks for your time.

ggplot2 r ngs

1 answer

When I read this I thought "I bet there is some trick you could do with grid", and google suggest maybe there is? http://stackoverflow.com/questions/13297155/add-floating-axis-labels-in-facet-wrap-plot

I was searching using the incorrect keywords. Thanks!

I moved this to an answer so it's easy to bookmark :)

Log in to answer this question.