I am trying to replicate the example shown here, made with rayshader
package:
https://www.rayshader.com/reference/plot_gg.html
I was focused in particular on the histogram. Below I report the code:
library(ggplot2)
library(viridis)
library(rayshader)
library(tidyverse)
mtplot <- ggplot(mtcars) +
geom_point(aes(x=mpg,y=disp,color=cyl)) +
scale_color_continuous(limits=c(0,8))
mtplot
plot1 <- plot_gg(mtplot, width=3.5, sunangle=225, preview = TRUE)
plot2 <- plot_gg(mtplot, width=3.5, multicore = TRUE, windowsize = c(1400,866), sunangle=225,
zoom = 0.60, phi = 30, theta = 45)
render_snapshot(clear = TRUE)
My first problem is when I try to make plot1 and plot2 that I get the following error:
Error in hillshade[, , 1] * scales::rescale(shadowmap, c(max_darken, 1)) :
arrays incompatible
I would like to understand why and if it is possible to fix tis error.
My second question is, in case of work, how to export the image generated from plot1
and plot2
? I tried with other examples with ggsave()
but it is not working. Is there any other way?
Thank you in advance for every support.