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)
<- matrix(c(1, -.75, -.75, 1), ncol = 2)
s <- mvtnorm::rmvnorm(500, sigma = s)
obs <- plot_ly(data = mtcars, x = ~hp, y= ~mpg)
fig <- subplot(
fig2 %>% add_markers(alpha = 0.2),
fig %>% add_histogram2d()
fig
)
fig2