Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase resolution of R rayshader image

I'm trying to make an image using rayshader package. I've been happy that I've been able to create a png file using code like so:

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")

Unfortunately, I can't figure out how to make the output image be a higher resolution. I've tried adjusting the windowsize which at low values seems to make a difference, but I've hit some sort of ceiling where the resolution of the output image won't go above 1372 x 893. What can I do to get an output image that is around 3200 x 3200 resolution?

Thanks!

enter image description here

like image 675
Jacqueline Nolis Avatar asked Nov 11 '19 07:11

Jacqueline Nolis


1 Answers

Currently, rayshader is limited by rgl's lack of support for device sizes greater than the resolution of the screen. I tested it out on my 1440p monitor, and I was able to get render_snapshot() to create an image 2564x1421 (approximately the resolution of a 1440p monitor). If your monitor supports higher resolutions, you may be able to increase the snapshot size by temporarily increasing your desktop resolution. Otherwise, it's currently a limitation (see this github issue):

https://github.com/tylermorganwall/rayshader/issues/28

However, if you have the time/patience and don't mind the slightly different type of image it produces, render_highquality() uses a completely different rendering engine and can be set to any size output. Just set the width and height arguments to the desired size when calling that function.

like image 188
Tyler Avatar answered Nov 03 '22 10:11

Tyler