Keep a 2d shadow of a 3d geom

Many 3d geoms have the ability to include a 2d “shadow” of the 3d geometry.

When drawing with selected 3d geoms, set keep2d = TRUE to keep a flat 2d rendering of the 3d geometry.

Default: Keep2d = FALSE

plot_df <- expand.grid(
  x = 1:10,
  y = 1:10
)

plot_df$z <- runif(100)


p <- ggplot(plot_df) + 
  geom_tile_z(aes(x=x, y=y, z=z, fill = z), alpha = 0.3) + 
  scale_z_continuous(range = c(100, 200))

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Render Plot in 3d with {devoutrgl}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
devoutrgl::rgldev(fov = 30, view_angle = -30)
p
invisible(dev.off())

Use your mouse, mouse buttons and scrollwheel to manipulate the 3d plot

Set Keep2d = TRUE to preserve a 2d ‘shadow’

Note: keep2d is not supported by all geoms.

plot_df <- expand.grid(
  x = 1:10,
  y = 1:10
)

plot_df$z <- runif(100)


p <- ggplot(plot_df) + 
  geom_tile_z(aes(x=x, y=y, z=z, fill = z), alpha = 0.3, keep2d = TRUE) + 
  scale_z_continuous(range = c(100, 200))

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Render Plot in 3d with {devoutrgl}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
devoutrgl::rgldev(fov = 30, view_angle = -30)
p
invisible(dev.off())

Use your mouse, mouse buttons and scrollwheel to manipulate the 3d plot