How can I remove black background from the 3D plot using plot_gg() with Rayshader in R?

196 Views Asked by At

I am using the rayshader package in R to render a 3D plot with plot_gg() function. I get a black background in the plot and want to remove it.

Here is my code:

gg_ma = ggplot(ma_sff) +
  geom_sf(aes(fill = pro.pop), lwd=0) +
  geom_sf(data=river3, col="white") +
  annotate(geom="text", x=104.5, y=16, color="red", size=7.5, label= paste(round(ma_sff$prop.ma[1],1), "% dân số", sep = "")) +
  scale_fill_viridis("Tỉ lệ (%)", direction = -1, option = "viridis") +
  ggtitle("Họ Mã") +
  theme_bw() +
  theme(text = element_text(size=15), axis.text.x = element_text(size=15), axis.text.y = element_text(size=15), legend.text=element_text(size=15)) +
  theme(legend.key.height = unit(10, "mm"),
        legend.key.width = unit(1, "mm"))

plot_gg(gg_ma, multicore = TRUE, raytrace = T, width = 10, height = 15, 
       scale = 300, windowsize = c(3500, 2165), zoom = 0.6, phi = 30, theta = 30, background = "white")

This is what I get

What can I do?

Thanks!

0

There are 0 best solutions below