The following code using plotly produces a 3d paraboliod in the viewing window of Rstudio, which can be rotated with the cursor.
Two related questions:
(1) "Save as image" in the Viewer works great. I can get the angle I want in the viewing window that pops up before saving. But is there any way to automate that, so that I can either
(a) fix an angle and produce a png while looping thru a parameter in the original code (changing the surface) or
(b) rotate through some angle about an axis, while saving the .png files?
(I know how to then use GIMP to produce a GIF).
p<-seq(from=-10, to=10, length.out = 30)
q<-p
f <- function(p, q) { p^2 + q^2}
m <- outer(p, q, f)
plot_ly() %>% add_surface(x = ~p, y = ~q, z = ~m, opacity=5)
I've not used plotly before, but I think this page will be helpful:
From what I understand, this should do the job:
library(plotly)
p <- seq(from = (-10),
to = 10,
length.out = 30)
q <- p
f <- function(p, q) return((p ^ 2) + (q ^ 2))
m <- outer(X = p,
Y = q,
FUN = f)
plot_ly() %>%
add_surface(x = ~p,
y = ~q,
z = ~m,
opacity = 5) %>%
orca(file = "plotly_save_png_image.png")
Unfortunately, I haven't been able to try this. For some reason, the windows-release.zip for installing orca is detected as virus. I'll try to download it once again and update this post.
Thanks very much! I'll try to install orca on my Mac.
However:
(1)it seems that orca has no commands to choose the perspective.
(2) I can already choose the perspective in Rstudio doing Export/Save as Image in the Viewer.
here is what I can get: So I don't see any advantage to using orca yet.
(2) it is command-line which means that it may not be possible for me to
loop it and produce a sequence of images for an animation....
(3) according to your link, the pdf version is pay-only from Plotly. The pdf may be higher resolution...I don't really want to pay if not necessary!