英文:
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)
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
我认为rayshader
和ggplot 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论