我想知道是否有人知道将3d图表作为视频导出的方法(更具体地说,这是可以本地完成的,还是需要辅助)?
导出静态图像很简单,导出交互式的图形对于嵌入HTML等也很好。
假设我有一个3D图表,所以我只想慢慢地旋转,如果图像可以被旋转一个给定的间隔,一个图像可以无限地旋转,也许是在一个循环中--但是我想知道这是否在某种程度上是本地支持的呢?
有人知道一个好策略吗?
解决方案理想的R/RStudio,但由于巧妙地是跨平台,任何解决方案考虑。
发布于 2016-09-01 18:16:58
供日后参考:
能够迭代多个视角的关键在于相机控制的“眼睛”,这个巧妙的帮助中心向我指出了这一点:
https://plot.ly/r/reference/#layout-scene-camera
camera = list(eye = list(x = 1.25, y = 1.25, z = 1.25))) #1.25 is default这个问题在这里得到了某种回答,尽管搜索上面所述的特定查询没有找到它:
enter link description here
我在脚本中使用了一个for循环,将迭代器传递给一个三角函数,该函数为摄像机协调绘制一个圆,在每一步绘制一个新的图像。
(x,y) =cos(θ)+sin(θ)

最终的代码如下:
# assume dataset read in, manipulated and given as a matrix in "matrix"
matrix.list <- list(x = temp, y = scan, z = matrix)
font.pref <- list(size=12, family="Arial, sans-serif", color="black")
x.list <- list(title = "X", titlefont = font.pref)
y.list <- list(title = "Y", titlefont = font.pref)
z.list <- list(title = "Z",titlefont = font.pref)
zoom <- 2
for(i in seq(0,6.3,by=0.1){
# 6.3 is enough for a full 360 rotation
outfile <- paste(file,"plot",i, sep = "_")
graph <- plot_ly(matrix.list, x = temp, y = scan, z = z,
type="surface") %>%
layout(scene=list(xaxis = x.list,
yaxis = y.list,
zaxis = z.list,
camera = list(eye = list(x = cos(i)*zoom, y = sin(i)*zoom, z= 0.25))))
# The above camera parameters should orbit
# horizontally around the chart.
# The multiplier controls how far out from
# from the graph centre the camera is (so
# is functionally a 'zoom' control).
graph
plotly_IMAGE(graph, username="xxx", key="xxx",
out_file = paste(outfile,"png", sep="."))
}、NB、、文件的数量以及它们的分辨率最终都会占用相当大的空间。
NB 2 --我在构造它的时候忘记了,它的免费API限制你每天调用50个API,所以如果你想渲染一个视频,调整你的帧等等,相应的.
https://stackoverflow.com/questions/39228237
复制相似问题