GGplot adding scales under specific graphs.
1
1
Entering edit mode
9.6 years ago
smilefreak ▴ 420

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 • 2.5k views
ADD COMMENT
5
Entering edit mode
9.6 years ago
David W 4.9k

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

ADD COMMENT
1
Entering edit mode

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

ADD REPLY
0
Entering edit mode

I was searching using the incorrect keywords. Thanks!

ADD REPLY

Login before adding your answer.

Traffic: 2701 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6