I'm trying to fix this issue for quite some time now and no code seems to work here. I'm not that experienced in R, so maybe my problem is easy to fix. The following code shall present an Alluvial plot which links Bee nests to certain Trees. The only thing that won't work is the fontsize of the Species on both sites, so that they will not overlap.
I´ve tried ggplot + theme(text=element_text(size=...)
; also theme(axis.text.x=element_text(size=...)
or add size=... in every command shown below. Is the fontsize connected to the "stratum" stat?
ggplot(data = trees,
aes(axis1 = trees$Bee_species, axis2 = trees$Tree_species, y = trees$obs)) +
geom_alluvium(aes(fill = trees$Bee_species)) +
geom_stratum(width=0.50) +
geom_text(stat = "stratum", aes(label = after_stat(stratum))) +
scale_x_discrete(limits = c("Bee_species", "Tree_species"),
expand = c(0.40, 0.40))+
theme_void()+
theme(legend.position = "none") +
scale_fill_manual(values = c("purple", "green", "blue", "red", "turquoise", "yellow"))
Here the table:
dput(trees)
structure(list(Bee_species = c("Apis_mellifera", "Lestrimelitta_sp",
"Lestrimelitta_sp", "Partamona_orizabaensis", "Partamona_orizabaensis",
"Partamona_orizabaensis", "Partamona_orizabaensis", "Partamona_orizabaensis",
"Partamona_orizabaensis", "Partamona_orizabaensis", "Partamona_orizabaensis",
"Partamona_orizabaensis", "Partamona_orizabaensis", "Partamona_orizabaensis",
"Partamona_orizabaensis", "Partamona_orizabaensis", "Partamona_orizabaensis",
"Partamona_orizabaensis", "Partamona_orizabaensis", "Scaptotrigona_subobscuripennis",
"Scaptotrigona_subobscuripennis", "Scaptotrigona_subobscuripennis",
"Scaptotrigona_subobscuripennis", "Scaptotrigona_subobscuripennis",
"Scaptotrigona_subobscuripennis", "Scaptotrigona_subobscuripennis",
"Scaptotrigona_subobscuripennis", "Tetragonisca_angustula", "Tetragonisca_angustula",
"Tetragonisca_angustula", "Tetragonisca_angustula", "Tetragonisca_angustula",
"Tetragonisca_angustula", "Tetragonisca_angustula", "Trigona_corvina",
"Trigona_corvina", "Trigona_corvina", "Trigona_corvina", "Trigona_corvina"
), Tree_species = c("tronco_muerto", "Ficus_jimenesii", "Spathodea_campanulata",
"Bambusa_vulgaris", "Cedrela_odorata", "Cojoba_arborea", "Cordia_eriostigma",
"Cupania_glabra", "Cupressus_lusitanica", "Elaeis_guineensis",
"Eucalyptus_sp", "Ficus_jimenesii", "Jacaranda_mimosifolia",
"Lagerstroemia_speciosa", "Phellodendron_sp", "Roystonea_regia",
"Spathodea_campanulata", "Tabebuia_rosea", "tronco_muerto", "Casuarina_equisetifolia",
"Cordia_eriostigma", "Cupressus_lusitanica", "Erythrina_poeppigiana",
"Ficus_costaricana", "Ficus_jimenesii", "Mangifera_indica", "tronco_muerto",
"Conifera", "Cupressus_lusitanica", "Ficus_costaricana", "Ficus_elastica",
"Ficus_jimenesii", "Spathodea_campanulata", "Tapirira_mexicana",
"Bambusa_vulgaris", "Citharexylum_sp", "Cupressus_sp", "Ficus_costaricana",
"Ficus_jimenesii"), obs = c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 4L,
1L, 1L, 8L, 1L, 1L, 3L, 2L, 5L, 2L, 3L, 1L, 1L, 2L, 1L, 2L, 3L,
1L, 1L, 1L, 1L, 1L, 1L, 5L, 1L, 1L, 1L, 1L, 1L, 1L, 2L)), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"), row.names = c(NA, -39L), groups = structure(list(
Bee_species = c("Apis_mellifera", "Lestrimelitta_sp", "Partamona_orizabaensis",
"Scaptotrigona_subobscuripennis", "Tetragonisca_angustula",
"Trigona_corvina"), .rows = structure(list(1L, 2:3, 4:19,
20:27, 28:34, 35:39), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -6L), .drop = TRUE))