Chapter 3 Statistical Charts
3.1 2D Histograms
A 2D histogram is a visualization of a bivariate distribution. And it looks like a heat map.
#
library(plotly)
s <- matrix(c(1, -.75, -.75, 1), ncol = 2)
obs <- mvtnorm::rmvnorm(500, sigma = s)
fig <- plot_ly(data = mtcars, x = ~hp, y= ~mpg)
fig2 <- subplot(
fig %>% add_markers(alpha = 0.2),
fig %>% add_histogram2d()
)
fig2