Hi ggplot2 group,
I have a question regarding manually controlling the axes in facet_wrap, not using scales="free"/"fixed".
# I KNOW THAT THIS PLOT IS UGLY, I AM RUBBISH AT MAKING DUMMY DATA THAT MIMICS MY REAL DATA.
### Question: I would like to change the y-axis ONLY IN FACETS 3-4 manually, but keep the
### axis for facets 1&2 (run the code and see plot).
### My problem is that in my real data facet 1&2 have similar data range (going up to values ~400)
### and 3&4 similar (ranging from ~1-16).
### When I set the scales="free" it all looks quite good, except for that the axes are
### slightly nudged in facet 3 compared with facet 4. I would therefore, for clarity, like to
### set these axes as identical, but still keep the axes for facets 1&2.
### How can I tweak facet_wrap so as to manually set the y-axes?
### Some dummy data:
mydata<- data.frame(factor1 = factor(rep(LETTERS[1:6], each = 80)),
factor2 = factor(rep(c(1:5), each = 16)),
factor3 = factor(rep(c(1:4), each = 4)),
var1 = rnorm(120, mean = rep(c(0, 3, 5), each = 40),
sd = rep(c(1, 2, 3), each = 20)),
var2 = rnorm(120, mean = rep(c(6, 7, 8), each = 40),
sd = rep(c(1, 2, 3), each = 20)))
p <- ggplot(mydata,aes(x=factor1,y=var1))+
geom_point(mapping=aes(shape=factor2))+
facet_wrap(~factor3, scales = "free")
Many thank's!
best
Anna Zakrisson
Anna Zakrisson Braeunlich
PhD student
Department of Ecology, Environment and Plant Sciences
Stockholm University
Svante Arrheniusv. 21A
SE-106 91 Stockholm
Sweden/Sverige
Lives in Berlin.
For paper mail:
Katzbachstr. 21
D-10965, Berlin