Visualising a function geom_point_z

geom_point_z renders points as circles by representing them as n-sided polygons. By setting the npolys parameters, the user can control the fidelity of the circle representation.

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Create plot with geom_point_z
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
func_df <- expand.grid(x = seq(-6, 6, 0.2), y=seq(-6, 6, 0.2)) %>%
  mutate(
    z = sin(sqrt(x*x + y*y))
  )

p <- ggplot(func_df) +
  geom_point_z(aes(x, y, z = z, colour = z), extrude = FALSE, 
               extrude_face_alpha = 0.1, size = 3, npolys = 3) +
  labs(
    title = "ggrgl::geom_point_z()",
    subtitle = "with {devoutrgl}"
  ) + 
  theme_ggrgl() +
  scale_colour_viridis_c() + 
  coord_equal() + 
  theme(legend.position = 'none')


#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 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

geom_point_z

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Create plot with geom_point_z
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
N <- 100
spiral_df <- data.frame(zl = seq(0, 30, length.out = N)) %>%
  mutate(
    xl = sin(zl),
    yl = cos(zl),
    xp = xl + rnorm(N) * 0.05,
    yp = yl + rnorm(N) * 0.05,
    zp = zl + rnorm(N) * 0.05
  )


p <- ggplot(spiral_df) +
  geom_path_3d(aes(xl, yl, z = zl), alpha = 0.3) + 
  geom_point_z(aes(xp, yp, z = zp, colour = zp), size = 6) +
  labs(
    title = "ggrgl::geom_point_z()",
    subtitle = "with {devoutrgl}"
  ) + 
  theme_ggrgl() +
  theme(legend.position = 'none') + 
  coord_equal()

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

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