Hey,
I would like to do two things with my following plot.
- only have one row of subplots. Using plot_layout(nrow = 1) does not solve my issue, as the nine subplots seems to be considered as one. If I set plot_layout(nrow = 2) then the nine subplots are squished in the top half of the plotting area.
- have automatic x axis scales for each subplot. Since Ligand A and F have very high Freq value, it is not possible to make out the difference between the Freq of C, D , G ,I ...
Thanks!
library(ggplot2)
library(tidyr)
library(dplyr)
library(stringr)
library(tidyverse)
library(patchwork)
Ligand<-c("A","A","A","B","B","B","C","C","C","D","D","D","E","E","E","F","F","F","G","G","G","H","H","H","I","I","I")
Element<-c("24","25","26","24","25","26","24","25","26","24","25","26","24","25","26","24","25","26","24","25","26","24","25","26","24","25","26")
Freq<-c(54300,21025,4026,0,0,0,105,548,64,0,45,97,0,0,0,51097,4166,154,12,224,548,0,0,0,45,20,8)
df1<-data.frame(Ligand,Element,Freq)
ggplot(df1, aes(x=Element, y=Freq))+
geom_bar(fill="black",stat = "identity")+
coord_flip()+
facet_wrap(~Ligand)+
geom_text(data=subset(df1,Freq != 0),aes(label = Freq), vjust= 0.5, hjust = "left",size = 2.5, colour = "black")+
plot_layout(nrow = 1)+
theme(
panel.background=element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
)