Closed storopoli closed 3 years ago
I am pretty sure the geom_ filled layers return a discrete variable for coloring, which plotgg has issues with. Try using the stat histogram/density flavor of ggplot layers. Given the MVN dist, you might also consider stat_bin2d() or stat_binhex() Y
You can force these layers to return continuous values - per the opening vignette, try this:
library(ggplot2) library(mnormt) library(MASS) library(rayshader) set.seed(123) mus <- c(0, 0) sigmas <- c(1, 1) r <- 0.8 Sigma <- diag(sigmas) Sigma[1, 2] <- r Sigma[2, 1] <- r dft <- data.frame(mvrnorm(1e5, mus, Sigma)) gg <- ggplot(dft, aes(X1, X2)) + stat_density_2d(aes(fill = stat(nlevel)), geom = "polygon", n = 100, bins = 10, contour = TRUE)
plot_gg(gg, triangulate = TRUE, width = 3, height = 3, scale = 250)
require(hexbin) gg <- ggplot(dft, aes(X1, X2)) + stat_binhex()
plot_gg(gg, raytrace = F, triangulate = TRUE, width = 3, height = 3, scale = 250)
Thank you very much!
Thanks for handling this one, @wilrogers!
Guys, I'm trying to use ray shader to generate a 3-D visualization of a bivariate normal distribution using
MASS::mvrnorm
and I get a strange error:Created on 2021-02-11 by the reprex package (v1.0.0)