I have my data:
new_df <- structure(list(Group = c("k__Bacteria;p__Proteobacteria;c__Alphaproteobacteria;o__Rhodospirillales;f__Rhodospirillaceae;g__Skermanella",
"k__Bacteria;p__Proteobacteria;c__Alphaproteobacteria;o__Rhodospirillales;f__Rhodospirillaceae;g__Skermanella",
"k__Bacteria;p__Proteobacteria;c__Alphaproteobacteria;o__Rhodospirillales;f__Rhodospirillaceae;g__Skermanella",
"k__Bacteria;p__Proteobacteria;c__Alphaproteobacteria;o__Rhodospirillales;f__Rhodospirillaceae;g__Skermanella"
), Percentile_0 = c(1, 1, 1, 22), Percentile_25 = c(1, 17.5,
16.75, 37), Percentile_50 = c(1, 23, 29, 39), Percentile_75 = c(9,
31.75, 33, 41.75), Percentile_100 = c(35, 47, 93, 50), Type = c("CC",
"CCS", "CS", "SCS")), row.names = c(NA, -4L), class = "data.frame")
I have my plot that looks like this
library(stringr) # for strwrap
bp <- ggplot(data = new_df, aes(x = Group, group = Type, fill = Type)) +
geom_boxplot(
stat = "identity",
aes(
ymin = Percentile_0,
lower = Percentile_25,
middle = Percentile_50,
upper = Percentile_75,
ymax = Percentile_100
)
) +
theme_classic() +
theme(axis.text.x=element_text(size=rel(0.45), angle=90))+
labs(x="Taxa", y="Sequence abundance")
I wanted to wrap the x-axis text. I tried +
scale_x_discrete(labels = function(x) str_wrap(x, width = 10))
based on this thread here which doesn't work for me. How do I wrap the axis text by the delimiter semicolon ;
?