Hi,
I could not find the way how to get labels generated by stat_summary() for all groups at, say, y = 0. If you also knew how to change the decimal mark to ",", I would be very grateful.
many thanks,
Jakub
finis <- structure(list(red_izo = c("600084302", "600084027", "600084485",
"600084345", "600084540", "600084558", "600106144", "600115372",
"600107787", "600112624", "600135811", "600135829", "600135837",
"600038017", "600038009", "600038114", "600037991", "600037983",
"600036049", "600036006"), pocet_pracovniku = c(3.5, 3, 1.1671,
3.5, 2.6809, 2.35, 4.3968, 4.3036, 2.7649, 1.1, 1.9, 4.4935,
2.4645, 3.4166, 2.9128, 2, 3.2917, 2.5, 3.875, 5.0834), tercil_MS = c("nad 70 žáků",
"nad 70 žáků", "mezi 35 a 70 žáky", "nad 70 žáků", "nad 70 žáků",
"mezi 35 a 70 žáky", "nad 70 žáků", "nad 70 žáků", "nad 70 žáků",
"mezi 35 a 70 žáky", "mezi 35 a 70 žáky", "nad 70 žáků",
"nad 70 žáků", "nad 70 žáků", "nad 70 žáků", "nad 70 žáků",
"nad 70 žáků", "nad 70 žáků", "nad 70 žáků", "nad 70 žáků"
), zriz = c("2", "2", "2", "2", "2", "2", "2", "2", "2", "2",
"2", "2", "2", "2", "2", "2", "2", "2", "2", "2"), zrizovatel = c("veřejné",
"veřejné", "veřejné", "veřejné", "veřejné", "veřejné",
"veřejné", "veřejné", "veřejné", "veřejné", "veřejné",
"veřejné", "veřejné", "veřejné", "veřejné", "veřejné",
"veřejné", "veřejné", "veřejné", "veřejné"), tercil = structure(c(3L,
3L, 2L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L), .Label = c("do 35 žáků", "mezi 35 a 70 žáky",
"nad 70 žáků"), class = "factor")), row.names = c(NA, -20L
), class = c("tbl_df", "tbl", "data.frame"))
library(stringr)
library(ggplot2)
plot <- ggplot(finis, aes(x = tercil_MS, y = pocet_pracovniku, fill = tercil_MS,
group = tercil_MS)) +
geom_boxplot()+
stat_summary(aes(label=str_c("průměr = ", round(..y..,1)), fontface = "bold", ),
fun=mean, geom="text", color = "#981E3D")+
scale_fill_manual(values=c("#F2CE6E", "#EF726B","#74496B", "#67A88F")) +
theme_minimal() +
theme(legend.position = 'none',
legend.title = element_blank(),
text=element_text(size=15, family="Fira Sans Condensed"),
plot.title = element_text(margin=margin(0,0,15,0)),
axis.title.x=element_blank(),
axis.title.y=element_blank(),
panel.spacing = unit(2, "lines"),
panel.grid.major.x = element_blank()
) +
scale_y_continuous(label=scales::comma_format(accuracy = 1, scale = 1, prefix = "", suffix = "",
big.mark = " ", decimal.mark = ","),
limits = c(0,5)) +
ggtitle("Průměrný počet nepedagogických zaměstnanců ve veřejných MŠ")
plot
#> Warning: Removed 1 rows containing non-finite values (stat_boxplot).
#> Warning: Removed 1 rows containing non-finite values (stat_summary).
Created on 2022-08-02 by the reprex package (v2.0.1)