In speziellen Fällen kann man sich auch nicht nur Normalverteilungen einzelner Variablen ausgeben lassen, sondern bivariate Normalverteilungen. Somit lässt sich visualiseren, ob die Verteilung beider Variablen ebenfalls annähnerd normalverteilt ist, oder eben nicht. Dazu nutzen wir die Funktion geom_bin2d()
:
ggplot(
pss,
aes(
trstplt,
trstlgl
)
) +
geom_bin2d(binwidth = 1) +
scale_fill_continuous(
low = "lavenderblush",
high = "red"
)
## Warning: Removed 23 rows containing non-finite outside the scale range
## (`stat_bin2d()`).
Bivariate Normalverteilungen lassen sich auch über die Dichte darstellen mit der Funktion stat_density_2d()
:
ggplot(
pss,
aes(
trstplt,
trstlgl
)
) +
stat_density_2d(
aes(fill = ..level..),
geom = "polygon"
) +
scale_fill_continuous(
low = "lavenderblush",
high = "red"
)
## Warning: The dot-dot notation (`..level..`) was deprecated in ggplot2 3.4.0.
## ℹ Please use `after_stat(level)` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: Removed 23 rows containing non-finite outside the scale range
## (`stat_density2d()`).