Something like this should be a decent starting point... I think.
It's not perfect, but should get you on the way to doing what you want.
library(reshape)
library(ggplot2)
library(data.table)
#library(ggExtra)
library(gridExtra)
# base code was taken from here and modified
# https://stackoverflow.com/questions/54638898/how-to-plot-proportion-data-with-a-bubble-plot-in-r
#
# code also taken from here (to reduce spacing)
# https://stackoverflow.com/questions/15556068/removing-all-the-space-between-two-ggplots-combined-with-grid-arrange
Species <- as.character(c(1:12))
name1 <-as.numeric(c(0.17,0.011,0.022,0.003,0.51,0.1,0.01,0.03,0.004,0.06,0.07,0.01))
name2<-as.numeric(c(0.197,0.005,0.027,0.01,0.337,0.157,0.008,0.038,0.017,0.17,0.032,0.002))
data<-as.data.frame(cbind(Species,name1,name2))
data$name1 <- as.numeric(as.character(data$name1));
data$name2 <- as.numeric(as.character(data$name2))
data2<-melt(data)
# gets a roughly similar sort of plot
p <- ggplot2::ggplot(data2,aes(x=variable, y=factor(Species, levels=unique(Species))))+
geom_point(aes(size=value))+
labs(y="Prey Items",x="Species")+
theme_classic() +
scale_size_area( limits = c(0,1),max_size = 20) +
#geom_richtext(position='identity',aes(label=Species), fill="grey", hjust = +2.5)
geom_richtext(position='identity',
aes(x='name1',label=factor(Species),
width = unit(0.01, "npc")),
hjust = 3.0,
fill="grey") +
# remove the y axis and the x axis ticks
theme(axis.line =element_blank(),
axis.title.y = element_blank(),
axis.ticks.y = element_blank(),
axis.text.y=element_blank(),
plot.margin=unit(c(1,1,1,1), "cm"),
legend.position = "none")
# shows the first graph
p
# create new data with additional variables (more species??)
Species <- as.character(c(13:18))
name1 <-as.numeric(c(0.17,0.011,0.022,0.003,0.51,0.1))
name2<-as.numeric(c(0.197,0.005,0.027,0.01,0.337,0.157))
data4<-as.data.frame(cbind(Species,name1,name2))
data4$name1 <- as.numeric(as.character(data4$name1));
data4$name2 <- as.numeric(as.character(data4$name2))
data4<-melt(data4)
# combine the data for a full set
data5 = rbind(data2, data4)
# plot the second figure
p2 <- ggplot2::ggplot(data5,aes(x=variable, y=factor(Species, levels=unique(Species))))+
geom_point(aes(size=value))+
labs(y="Prey Items",x="Species")+
theme_classic() +
scale_size_area( limits = c(0,1),max_size = 20) +
#geom_richtext(position='identity',aes(label=Species), fill="grey", hjust = +2.5)
geom_richtext(position='identity',
aes(x='name1',label=factor(Species),
width = unit(0.01, "npc")),
hjust = 3.0,
fill="grey") +
# remove the y axis and the x axis ticks
# the plot margin changes the horizzontal space between the second plot and first
theme(axis.line =element_blank(),
axis.title.y = element_blank(),
axis.ticks.y = element_blank(),
axis.text.y=element_blank(),
plot.margin=unit(c(1,1,1,-3), "cm"))
# shows the second graph
p2
# combine the plots into one (expand the display if it looks iffy in R/Rstudio)
grid.arrange(p,p2, ncol=2)