2

I have some data from lab equipment that can be represented as a matrix by a contour plot/heatmap.

I would like to try illustrating this data in R with the rayshader package.

My problem is that the data is far from square in shape, the matrix is 33 rows by 48003 columns. When I plot this with rayshader I get a thin line:

library(dplyr)
library(rayshader)

set.seed(1742)
df <- matrix(rnorm(10000), nrow = 10)
rownames(df) <- 1:10
colnames(df) <- seq(0.01, 10, 0.01)

df %>%
  sphere_shade(texture = "desert") %>%
  plot_map()

Is there a way to make rayshader plot this as a square by manipulating the x/y aspect ratios? Or to plot them on an equivalent scale (one dimension collects data much faster than the other)? I can't find anything in the docs.

In this example, I tried naming the rows and columns so they were both collected over 10 minutes, but it didn't change the result.

The end result should look similar to:

library(plotly)

set.seed(1742)
plot_ly(z = ~matrix(rnorm(10000), nrow = 10)) %>%
  add_surface()

enter image description here

Many thanks.

Paul
  • 2,877
  • 1
  • 12
  • 28

1 Answers1

1

Solution for rayshader::plot_3d() is to use scale = c(x, y, z), which will alter the x/y/z aspect ratios. This was hidden, but didn't take that much sluthing to find the answer. It is a setting in rgl::par3d(), which is called by plot_3d().

However, I couldn't get plot_map() to work. When I tried adding the argument asp = 1, which is used by rgl::par3d(), it threw errors.

Paul
  • 2,877
  • 1
  • 12
  • 28