data(Donner, package = "vcdExtra")
# three interfaces to the same underlying plot
logist_plot(Donner$age, Donner$survived, marginal = "points")
logist_plot(Donner[, c("age", "survived")], marginal = "hist")
logist_plot(survived ~ age, data = Donner, marginal = "density")
# post-hoc labels and themes work in histogram mode
logist_plot(survived ~ age, data = Donner, marginal = "hist") +
ggplot2::labs(title = "Survival of the Donner Party") +
ggplot2::theme(plot.title = ggplot2::element_text(face = "bold"))
# layer-specific customization; scoped lists override graphical defaults
logist_plot(
survived ~ age, data = Donner, marginal = "hist",
fit.args = list(linewidth = 2, fill = "lightblue"),
marginal.args = list(colour = "black", linewidth = 0.2, alpha = 0.8)
)
# convenience wrappers -- marginal= fixed, still get all calling conventions
logist_point(survived ~ age, data = Donner)
logist_hist(survived ~ age, data = Donner)
logist_density(survived ~ age, data = Donner, adjust = 1.25)
# grouped fits and marginals; grouped density lanes extend outward from 0 and 1
logist_point(survived ~ age, data = Donner, group = "sex")
logist_density(
survived ~ age, data = Donner, group = "sex",
group.colors = c(Female = "#D55E00", Male = "#0072B2"),
marginal.args = list(alpha = 0.35, linewidth = 0.6)
)
Run the code above in your browser using DataLab