R gist — Plot an interactive 3D RGB colour space

Gist
Author

Stefano Coretta

Published

January 29, 2021

library(plotly)
codes <- seq(0, 255, 25.5)

rgb <- expand.grid(
  r = codes,
  g = codes,
  b = codes
) %>%
  mutate(colour = rgb(r, g, b, maxColorValue = 255))
rgb %>%
  plot_ly(x = ~r, y = ~g, z = ~b, marker = list(color = ~colour, size = 6))