# Small function to display plots only if it's interactive
p_ <- GGally::print_if_interactive
data(tips)
p_(ggally_colbar(tips, mapping = aes(x = smoker, y = sex)))
p_(ggally_rowbar(tips, mapping = aes(x = smoker, y = sex)))
# change labels' size
p_(ggally_colbar(tips, mapping = aes(x = smoker, y = sex), size = 8))
# change labels' colour and use bold
p_(ggally_colbar(tips,
mapping = aes(x = smoker, y = sex),
colour = "white", fontface = "bold"
))
# display number of observations instead of proportions
p_(ggally_colbar(tips, mapping = aes(x = smoker, y = sex, label = after_stat(count))))
# custom bar width
p_(ggally_colbar(tips, mapping = aes(x = smoker, y = sex), geom_bar_args = list(width = .5)))
# change format of labels
p_(ggally_colbar(tips,
mapping = aes(x = smoker, y = sex),
label_format = scales::label_percent(accuracy = .01, decimal.mark = ",")
))
p_(ggduo(
data = as.data.frame(Titanic),
mapping = aes(weight = Freq),
columnsX = "Survived",
columnsY = c("Sex", "Class", "Age"),
types = list(discrete = "rowbar"),
legend = 1
))
Run the code above in your browser using DataLab