# Small function to display plots only if it's interactive
p_ <- GGally::print_if_interactive
data(tips)
p_(ggbivariate(tips, "smoker", c("day", "time", "sex", "tip")))
# Personalize plot title and legend title
p_(ggbivariate(
tips, "smoker", c("day", "time", "sex", "tip"),
title = "Custom title"
) +
labs(fill = "Smoker ?"))
# Customize fill colour scale
p_(ggbivariate(tips, "smoker", c("day", "time", "sex", "tip")) +
scale_fill_brewer(type = "qual"))
# Customize labels
p_(ggbivariate(
tips, "smoker", c("day", "time", "sex", "tip"),
rowbar_args = list(
colour = "white",
size = 4,
fontface = "bold",
label_format = scales::label_percent(accurary = 1)
)
))
# Choose the sub-plot from which get legend
p_(ggbivariate(tips, "smoker"))
p_(ggbivariate(tips, "smoker", legend = 3))
# Use mapping to indicate weights
d <- as.data.frame(Titanic)
p_(ggbivariate(d, "Survived", mapping = aes(weight = Freq)))
# outcome can be numerical
p_(ggbivariate(tips, outcome = "tip", title = "tip"))
Run the code above in your browser using DataLab