Dear R community
In the meantime I made some progress:
ggplot(data = Fig2b, aes(x = BFF, y = Wert, fill = Effekt))+theme_bw()+
geom_bar(stat = "identity", width = 0.95) +
scale_y_continuous(limits=c(0,13), expand=c(0,0))+
facet_wrap(~Aspekt, strip.position = "bottom", scales =
"free_x") +
theme(panel.spacing = unit(0, "lines"),
strip.background = element_blank(),
strip.placement = "outside")+
theme(axis.title.x=element_blank())+
scale_fill_manual("Effekt", values = c("Neg" =
"red", "Neu" "darkgrey", "Pos" =
"blue"), labels=c("Negativ", "Nicht sign.",
"Positiv"))
Question
- Is it possible to present all the subpolots in one graph (not to
"lines")?
- I tried to change the angel of the x-axis. However, I was able to change
the first x-axis (BB...), but not the second one (Voegel....). Maybe this
would solve the problem.
- If not, is there another possibility to fix the number of subplots per
line?
Kind regards
Sibylle
-----Original Message-----
From: R-help <r-help-bounces at r-project.org> On Behalf Of SIBYLLE
ST?CKLI via
R-help
Sent: Saturday, December 16, 2023 12:16 PM
To: R-help at r-project.org
Subject: [R] ggplot 3-dimensions
Dear R-user
Does anybody now, if ggplot allows to use two x-axis including two
dimensions (similar to excel plot (picture 1 in the pdf attachmet). If yes,
how should I adapt my code? The parameters are presented in the input file
(attachment: Input).
Fig2b = read.delim("BFF_Fig-2b.txt", na.strings="NA")
names(Fig2b)
head(Fig2b)
summary(Fig2b)
str(Fig2b)
Fig2b$Aspekt<-factor(Fig2b$Aspekt, levels=(c("Voegel",
"Kleinsaeuger",
"Schnecken", "Regenwuermer_Asseln", "Pilze")))
### Figure 2b
ggplot(Fig2b,aes(Aspekt,Wert,fill=Effekt))+
geom_bar(stat="identity",position='fill')+
scale_y_continuous(limits=c(0,14), expand=c(0,0))+
labs(x="", y="Anzahl Studien pro Effekt")
Kind regards
Sibylle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ggplot_3dim.pdf
Type: application/pdf
Size: 5687 bytes
Desc: not available
URL:
<https://stat.ethz.ch/pipermail/r-help/attachments/20231217/c543c7de/attachment.pdf>