【问题标题】:plotly 'splom' type does not show scatter pointsplotly 'splom' 类型不显示散点
【发布时间】:2019-08-18 23:21:27
【问题描述】:

我只是复制粘贴此处找到的 splom 教程代码:https://plot.ly/r/splom/,但得到的输出没有绘制点:

代码:

library(plotly)

df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/iris-data.csv')
pl_colorscale=list(c(0.0, '#19d3f3'),
                   c(0.333, '#19d3f3'),
                   c(0.333, '#e763fa'),
                   c(0.666, '#e763fa'),
                   c(0.666, '#636efa'),
                   c(1, '#636efa'))

axis = list(showline=FALSE,
            zeroline=FALSE,
            gridcolor='#ffff',
            ticklen=4)

p <- df %>%
    plot_ly() %>%
    add_trace(
        type = 'splom',
        dimensions = list(
            list(label='sepal length', values=~sepal.length),
            list(label='sepal width', values=~sepal.width),
            list(label='petal length', values=~petal.length),
            list(label='petal width', values=~petal.width)
        ),
        text=~class,
        marker = list(
            color = as.integer(df$class),
            colorscale = pl_colorscale,
            size = 7,
            line = list(
                width = 1,
                color = 'rgb(230,230,230)'
            )
        )
    ) %>%
    layout(
        title= 'Iris Data set',
        hovermode='closest',
        dragmode= 'select',
        plot_bgcolor='rgba(240,240,240, 0.95)',
        xaxis=list(domain=NULL, showline=F, zeroline=F, gridcolor='#ffff', ticklen=4),
        yaxis=list(domain=NULL, showline=F, zeroline=F, gridcolor='#ffff', ticklen=4),
        xaxis2=axis,
        xaxis3=axis,
        xaxis4=axis,
        yaxis2=axis,
        yaxis3=axis,
        yaxis4=axis
    )
p

会话:

> sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] readxl_1.3.1     factoextra_1.0.5 shiny_1.3.2      plotly_4.9.0    
[5] ggplot2_3.2.0   

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1        cellranger_1.1.0  ggpubr_0.2        pillar_1.4.1     
 [5] compiler_3.5.0    later_0.8.0       viridis_0.5.1     tools_3.5.0      
 [9] dendextend_1.12.0 digest_0.6.19     jsonlite_1.6      tibble_2.1.3     
[13] gtable_0.3.0      viridisLite_0.3.0 pkgconfig_2.0.2   rlang_0.3.4      
[17] igraph_1.2.4.1    cli_1.1.0         rstudioapi_0.10   crosstalk_1.0.0  
[21] ggrepel_0.8.1     yaml_2.2.0        gridExtra_2.3     withr_2.1.2      
[25] dplyr_0.8.1       httr_1.4.0        htmlwidgets_1.3   grid_3.5.0       
[29] tidyselect_0.2.5  glue_1.3.1        data.table_1.12.2 R6_2.4.0         
[33] purrr_0.3.2       tidyr_0.8.3       magrittr_1.5      scales_1.0.0     
[37] promises_1.0.1    htmltools_0.3.6   assertthat_0.2.1  mime_0.7         
[41] colorspace_1.4-1  xtable_1.8-4      httpuv_1.5.1      labeling_0.3     
[45] lazyeval_0.2.2    munsell_0.5.0     crayon_1.3.4

我是否缺少一些图形软件来让 splom 工作?

【问题讨论】:

  • 你有什么错误信息吗?
  • @Chelmy88 我没有收到错误消息。
  • 从重新启动会话开始。即使模仿了您的会话信息,我也无法重现该错误:i.stack.imgur.com/jNcdw.png
  • 重启会话并不能解决问题。重新安装包也不行。
  • 我也面临同样的问题。真烦人。

标签: r plotly


【解决方案1】:

有同样的问题,原来是与 Rstudio 相关,而不是代码问题。在新窗口中打开(在浏览器中)为我解决了这个问题。

【讨论】:

    猜你喜欢
    • 2021-11-04
    • 1970-01-01
    • 2021-05-11
    • 2021-02-07
    • 2020-11-24
    • 2020-07-27
    • 2021-03-21
    • 2020-09-04
    • 1970-01-01
    相关资源
    最近更新 更多