How to determine camera perspective 3D graphics graphics in R?

I would like to change the default camera perspective for my 3D plot scatter plot, it is not clear from this how this should be done. I understand that the layout parameters should be included in the named list, but they cannot make it work for the β€œeye” and β€œcenter” camera parameters.

https://plot.ly/r/reference/#layout-scene-camera

It should be something like:

require(plotly)

scene=list(bgcolor='#990055',camera=list(eye=c(1,2,3)))

plot_ly(x=rnorm(100), y=rnorm(100), z=rnorm(100),
         type="scatter3d", mode='markers+lines') %>%  layout(scene=scene)
+4
source share
2 answers

It's a bit late, but hopefully it helps others who are looking for a solution to this. Here is an example:

library(plotly)
set.seed(123)

# Create Random Data
ds <- diamonds[sample(1:nrow(diamonds), size = 1000),]

scene = list(camera = list(eye = list(x = -1.25, y = 1.25, z = 1.25)))

plot_ly(ds, x = carat, y = cut, z = price, group = color, type = "scatter3d", mode = "markers",
        marker = list(opacity = 0.6, size = 4)) %>% 
  layout(title = "3D Scatter plot", scene = scene)
+3
source

In python, I set the default camera as follows:

scene=dict(cameraposition=[[-0.1, 0.5, -0.7, -0.2], [0.0, 0, 0.0], 2.8])

4 - , 3 - x, y, z, - . ; , : https://plot.ly/python/3d-plots-tutorial/#in-[7]

-1

Source: https://habr.com/ru/post/1619197/


All Articles