I want to create two different sizes of text in the labels of my facet wrap.
For example:
- Species X (size 14)
- Total catch (n=133) (size 12)
test <- read.csv(paste0(path, "Costello Artvgl2 for Stack.csv"), sep = ";", dec = ",", header = T)
str(test)
test$Wert <- factor(test$Wert, levels = c("one","two","three","four","five","six"))
test$Sampling.site <- factor(test$Sampling.site, levels = c("Species X Area T","Species Y Area T","Species X Area A","Species Y Area B","Species X Area B","Species Y Area C"))
levels(test$Sampling.site) <- c("Species X\nTotal catch (n=133)", "Species Y\nTotal catch (n=185)", "Species X\nSampling area A (n=57)", "Species Y\nSampling area B (n=122)",
"Species X\nSampling area B (n=76)", "Species Y\nSampling area C (n=63)")
theme_new <- function(base_size = 12, base_family = base_family){
theme_bw(base_size = base_size) %+replace%
theme(
axis.text.x = element_text(size = 8 ),
axis.text.y = element_text(size = 8 ),
axis.title.x = element_text(size = 12, vjust = 0.01),
axis.title.y = element_text(size = 12, vjust = 0.9, angle = 90),
plot.title = element_text(size = 10, face = "bold"),
legend.key= element_rect(colour= NA, fill =NA, size = 0.5),
legend.key.size = unit(1, "lines"),
legend.text = element_text(size = 8),
legend.title = element_blank(),
strip.background = element_rect(fill = NA, colour = NA),
strip.text = element_text(size = 8, face = "bold",hjust = 0.5, vjust = 0.9),
panel.background = element_rect(fill = "white"),
panel.border = element_rect(fill = NA, colour="black"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.margin = unit(1, "lines")
)
}
ggplot(test, aes(Fi, Pi),group=Wert)+
geom_point(aes(colour = factor(Wert),shape = factor(Wert)),size=3) +
scale_shape_manual(values=c(20,18,19,15,16,17))+
scale_x_continuous(limits=c(0, 1),breaks=c(0,0.2,0.4,0.6,0.8,1.0))+
scale_colour_brewer(type = "qual", palette = "Paired")+
scale_y_continuous(limits=c(0, 100),breaks=c(0,20,40,60,80,100))+
labs(x = "Frequency of occurrence", y = "Prey-specific abundance [%]")+
facet_wrap(~Sampling.site,scales = "free",ncol = 2) +
theme_new()
Is there a possibility to realize that?
ggtext
package easily solves this problem, I suggest accepting Claus Wilke's new answer, rather than mine. – Alaric