以供將來參考:
要能遍歷多個角度證明趴在攝像機控制「眼睛」鍵,plotly幫助中心指出我朝着這個:
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
這是一種回答在這裏,雖然尋找我的特定查詢如上沒發現它:
http://stackoverflow.com/questions/34178381/how-to-specify-camera-perspective-of-3d-plotly-chart-in-r
我在腳本中使用了for循環來將迭代器傳遞給一個三角函數,該函數繪製出相機座標的一個圓,並在每一步渲染一個新圖像。
(X,Y)= COS(THETA)+ SIN(THETA)
最終的代碼看起來是這樣的:
# 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 = "Temperature (˚C)",titlefont = font.pref)
y.list <- list(title = "Wavelength (nm)",titlefont = font.pref)
z.list <- list(title = "CD Intensity",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",
colors=c("black","grey","red"),
colorbar = list(title="CD Intensity")) %>%
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)))) # Should orbit horizontally around the chart, the multiplier just controls how far out from the graph centre the camera is.
graph
plotly_IMAGE(graph,
width = 1600,
height = 1400,
format = "png",
username="xxx",
key="xxx",
scale = 1,
out_file = paste(outfile,"png", sep="."))
}
NB文件數他們的決議可能會佔用相當數量的空間。
NB 2在構造此說plotly是你免費API限制到每天50 API調用我已經忘記了,所以如果你想呈現一個視頻,調整你的框架等,因此...
雖然downvoting這個問題是完全合法的...如果提供了一個建設性的意見,爲什麼需要提供...... –
你可以看一下'caTools'軟件包。我不認爲它可以有效地運作,但你可以用它來製作GIF。 – Vandenman
我沒有downvote,但我想原因是你的問題看起來像谷歌搜索可以修復。有許多軟件包可以從圖中創建動畫:使用'movie3d'打包'rgl',並打包'gganimate'。兩者都依賴於imagemagick,所以你可能也必須安裝它。 – DeveauP