简体   繁体   English

在RStudio Viewer中无法正确显示

[英]Plotly not displaying correctly in RStudio Viewer

I am using the plotly package for the first time to generate 3D plots. 我是第一次使用plotly包来生成3D图。 Although I am following the tutorial, the plot points don't appear in the RStudio Viewer. 虽然我按照教程进行操作,但绘图点不会出现在RStudio Viewer中。 Just an empty grid. 只是一个空格子。 在此输入图像描述

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')))

However, when I open the plot in a web browser, the points show up fine. 但是,当我在网络浏览器中打开图表时,积分显示正常。

I see a similar question here: Plotly in RStudio viewer 我在这里看到一个类似的问题: 在RStudio查看器中的Plotly

But after updating to the latest version of RStudio the points still do not appear. 但在更新到最新版本的RStudio之后,这些点仍未出现。 I am using R version 3.3.3 我使用的是R版本3.3.3

It seems an incompatibility between the 4.6.0 release of plotly and the 1.0.143 release of Rstudio. 这似乎是4.6.0版本的plotly与Rstudio的1.0.143版本之间不兼容。 Try using the release 4.5.6 release of plotly : 尝试使用版本4.5.6版本的plotly

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

It works nicely and the plot points now appear in the latest release of my RStudio. 它工作得很好,情节点现在出现在我的RStudio的最新版本中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM