Plotly 在 RStudio Viewer 中无法正确显示

Plotly not displaying correctly in RStudio Viewer

我第一次使用 plotly 包来生成 3D 图。尽管我正在按照教程进行操作,但绘图点并未出现在 RStudio Viewer 中。只是一个空的网格。

library(plotly)
packageVersion('plotly')
#[1] ‘4.6.0’

mtcars$am[which(mtcars$am == 0)] <- 'Automatic'
mtcars$am[which(mtcars$am == 1)] <- 'Manual'
mtcars$am <- as.factor(mtcars$am)

p <- plot_ly(mtcars, x = ~wt, y = ~hp, z = ~qsec, color = ~am, colors = c('#BF382A', '#0C4B8E')) %>%
  add_markers() %>%
  layout(scene = list(xaxis = list(title = 'Weight'),
                      yaxis = list(title = 'Gross horsepower'),
                      zaxis = list(title = '1/4 mile time')))

但是,当我在网络浏览器中打开绘图时,这些点显示正常。

我在这里看到一个类似的问题:Plotly in RStudio viewer

但是更新到最新版本的RStudio后,这些点还是没有出现。我正在使用 R 版本 3.3.3

plotly 的 4.6.0 版本和 Rstudio 的 1.0.143 版本似乎不兼容。尝试使用 plotly:

的 4.5.6 版本
devtools::install_version("plotly", version = "4.5.6", 
               repos = "http://cran.us.r-project.org")

效果很好,绘图点现在出现在我的 RStudio 的最新版本中。