我只复制粘贴在以下位置找到的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
我是否缺少一些图形软件来使花洒工作?
答案 0 :(得分:0)
具有相同的问题,事实证明它与Rstudio有关,而不是与代码问题有关。在新窗口中打开(在浏览器中)为我解决了该问题。