2

I've been trying to plot a 3D plot of some spatial polygons, but I cannot render the sides and edges of the polygons properly. Below is the code I used to produce the plot below.

# Produce the 2D plot first.
ggplot() +
      geom_sf(data = strips, aes(geometry = geometry, fill = total_fish, col = total_fish), col = "NA") +
      theme(legend.position = "left") + labs(fill = "Relative 
      fish biomass") +
      xlab("Longitude") + ylab("Latitude") +
      theme_bw() -> ppp
    ppp

# Render the 3D image.
plot_gg(ppp, multicore = T, width = 5, height = 5, scale = 350, raytrace = T, 
        windowsize = c(8000, 8000), zoom = 0.8, phi = 60, theta = 60)
Sys.sleep(0.2)
render_snapshot(clear = T)

enter image description here

THINGS I'VE ALREADY TRIED: Assigning a color to the edges, changing the thickness of the edges (by using the linewidth argument) playing with the pointcontract argument within the plot_gg function, changing the windowsize-scale-dimensions of the render.

Thanks for your help in advance, and please let me know if you need a fully reproducible code.

Zhiqiang Wang
  • 6,206
  • 2
  • 13
  • 27
KO 88
  • 55
  • 5

1 Answers1

1

I think that rayshader and ggplot 3.4.0 or later have some issues, using linewidth would not fix the problem. Hopefully, future updates of either or both packages will fix this. Meanwhile, you could switch back to ggplot 3.3.6 to clean 3D images.

Restart Rstudio:

library(remotes)
install_version("ggplot2", version = "3.3.6", repos = "http://cran.us.r-project.org")

Then, re-run your code should fix the problem. If not, please share a reproducible example. Others could test it on their machines.

Zhiqiang Wang
  • 6,206
  • 2
  • 13
  • 27
  • Thank you. Downgrading to the older version of ggplot2 + using the offset_edges=T solved the issue nearly fully. There is still some bleeding, but it is tolerable. – KO 88 Feb 27 '23 at 12:02