My question is closely related to this question. But I cannot figure out how it works for the subtitle and when you already have another theme in there as well.
I have data as follows:
library(dplyr)
library(ggplot2)
library(forcats)
df_a <- structure(list(`Sample Selection` = c("Answers Private", "Answers Private",
"Answers Public", "Answers Public", "All Participants", "All Participants"
), category = c("A. % mean tax compliance", "B. % mean corporate compliance",
"A. % mean tax compliance", "B. % mean corporate compliance",
"A. % mean tax compliance", "B. % mean corporate compliance"),
total = c(660, 550, 582, 485, 1242, 1035), percentage = c(40.4545454545455,
44.9090909090909, 45.7044673539519, 54.8453608247423, 42.914653784219,
49.5652173913043), count = c(267, 247, 266, 266, 533, 513
), p_value = c(0.0621323326097826, 0.0014205180679509, 0.0621323326097826,
0.0014205180679509, 0.00151992181366903, 0.00151992181366903
), stars = structure(c(".", "**", ".", "**", "**", "**"), legend = "0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1", class = "noquote")), row.names = c(NA,
-6L), class = c("data.table", "data.frame"))
Sample Selection category total percentage count p_value stars
1: Answers Private A. % mean tax compliance 660 40 267 0.0621 .
2: Answers Private B. % mean corporate compliance 550 45 247 0.0014 **
3: Answers Public A. % mean tax compliance 582 46 266 0.0621 .
4: Answers Public B. % mean corporate compliance 485 55 266 0.0014 **
5: All Participants A. % mean tax compliance 1242 43 533 0.0015 **
6: All Participants B. % mean corporate compliance 1035 50 513 0.0015 **
df_a %>%
ggplot(aes(x = category, y = percentage, fill = `Sample Selection`, label=sprintf("%.01f %%", round(percentage, digits = 2)))) +
geom_col(position = 'dodge') +
geom_text(position = position_dodge(width = .9), # move to center of bars
vjust = -0.5, # nudge above top of bar
size = 4) +
scale_fill_grey(start = 0.8, end = 0.5) +
theme_bw(base_size = 15) +
geom_signif(annotation=c("p=0.002"), y_position = c(70), xmin=c(0.7),
xmax=c(1.7)) + ## between ESCOT levels +
geom_signif(annotation=c("p=0.06", "p=0.001"), y_position = c(60, 60), xmin=c(1,2),
xmax=c(1.25,2.25)) + ## Within ESCOT levels but between groups
xlab("p-values from test of proportions") +
ylab("Percentage Compliant/Honest") +
ggtitle("Figure X.", subtitle = "p-values from test of proportions") +
scale_shape_manual(values = c('p_value' = 17), name = 'stars')
How would I change the font size of the subtitle in this case?