我正在尝试使用 rayshader 包制作图像。我很高兴能够使用如下代码创建一个 png 文件:
library(ggplot2)
library(rayshader)
example_plot <-
ggplot(data.frame(x=c(1,2,3),y=c(4,5,6),z=c(5,4,3)),aes(x=x,y=y,color=z)) + geom_point()
plot_gg(example_plot, width = 2, height = 2, multicore = TRUE, scale = 125,
zoom = 0.5, phi = 60, theta=-10, windowsize = c(3200, 3200), offset_edges = TRUE)
Sys.sleep(2.0)
render_depth(focus = 0.5, focallength = 100, fstop = 8, clear = TRUE,filename="example.png")
Run Code Online (Sandbox Code Playgroud)
不幸的是,我无法弄清楚如何使输出图像具有更高的分辨率。我试过调整窗口大小,在低值下似乎有所不同,但我已经达到了某种上限,输出图像的分辨率不会超过 1372 x 893。我该怎么做才能获得输出分辨率约为 3200 x 3200 的图像?
谢谢!
当我渲染 Rayshader 图形时,它会在我的 mac 上打开 Xquartz,没问题,但是如果我想将它包含在我的 Rmarkdown 文档中,它只显示代码,没有图形,该怎么办?我知道这是一个繁重的图形密集型渲染,但正在寻找任何提示。谢谢,下面是我的代码:
---
title: "rayshader"
author: "Daniel"
date: "6/16/2020"
output:
html_document:
self_contained: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r cars}
library(rayshader)
#Here, I load a map with the raster package.
loadzip = tempfile()
download.file("https://tylermw.com/data/dem_01.tif.zip", loadzip)
localtif = raster::raster(unzip(loadzip, "dem_01.tif"))
unlink(loadzip)
#And convert it to a matrix:
elmat = raster_to_matrix(localtif)
elmat %>%
sphere_shade(texture = "desert") %>%
add_water(detect_water(elmat), color = "desert") %>%
add_shadow(ray_shade(elmat, zscale = 3), 0.5) %>%
add_shadow(ambient_shade(elmat), 0) %>%
plot_3d(elmat, zscale …Run Code Online (Sandbox Code Playgroud)