annotation_raster
Creates annotation as high-performance rectangular tiling and convert them with ggplotly.
rainbow <- matrix(hcl(seq(0, 360, length.out = 50 * 50), 80, 70), nrow = 50) p <- ggplot(mtcars, aes(mpg, wt)) + geom_point() + annotation_raster(rainbow, 15, 20, 3, 4)
plotly::ggplotly(p)
rainbow <- matrix(hcl(seq(0, 360, length.out = 50 * 50), 80, 70), nrow = 50) p <- ggplot(mtcars, aes(mpg, wt)) + annotation_raster(rainbow, -Inf, Inf, -Inf, Inf) + geom_point()
plotly::ggplotly(p)
rainbow2 <- matrix(hcl(seq(0, 360, length.out = 10), 80, 70), nrow = 1) p <- ggplot(mtcars, aes(mpg, wt)) + annotation_raster(rainbow2, -Inf, Inf, -Inf, Inf) + geom_point()
plotly::ggplotly(p)
rainbow2 <- matrix(hcl(seq(0, 360, length.out = 10), 80, 70), nrow = 1) p <- ggplot(mtcars, aes(mpg, wt)) + annotation_raster(rainbow2, -Inf, Inf, -Inf, Inf, interpolate = TRUE) + geom_point()
plotly::ggplotly(p)