多边形边缘和边角在 rayshader 渲染中失真。

huangapple go评论71阅读模式
英文:

Polygon edges and sides distorted in rayshader render

问题

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)

英文:

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)

多边形边缘和边角在 rayshader 渲染中失真。

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.

答案1

得分: 1

我认为rayshaderggplot 3.4.0或更高版本存在一些问题,使用linewidth无法解决这个问题。希望以后更新这两个软件包中的一个或两个能够解决这个问题。与此同时,您可以切换回ggplot 3.3.6来生成清晰的3D图像。

重新启动Rstudio:

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

然后重新运行您的代码应该能够解决问题。如果没有,请提供一个可重现的示例。其他人可以在他们的计算机上测试它。

英文:

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.

huangapple
  • 本文由 发表于 2023年2月27日 15:48:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/75577912.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定