R Plotly: 3D surface reverse x-axis

Viewed 538

I am trying to setup the camera of a 3D surface plot such that the x axis goes from from left = 0 to right = 60, and the y axis from bottom = 0 to top = 80, while having the z axis on the left side.

There goes an example:

library(plotly)
library(magrittr)

plot_ly(z = ~volcano) %>%
  add_surface() %>%
  layout(scene = list(camera=list()))

This is the default output:
enter image description here

This is what I want:
enter image description here

I tried to change the x, y, and z parameters from the eye() function without success. I also tried to use xasix = list(autoarante = "reversed").

1 Answers

The eye vector determines the position of the camera, with a default of (x = 1.25, y = 1.25, z = 1.25).

To change the default to get the desired perspective, you can set the y in the camera eye to a negative value.

library(plotly)
library(magrittr)

plot_ly(z = ~volcano) %>%
  add_surface() %>%
  layout(scene = list(camera=list(eye = list(x = .8, y = -2, z = 1.25))))

Output

plotly plot of volcano with camera eye changed in layout

Related