绘图仪定制modebar
我试图使用绘图仪定制modebar,r,plotly,R,Plotly,我试图使用config从模式栏中删除按钮,但它要么返回错误,要么在控制台中显示文本,而不对绘图本身进行更改: myplot <- plot_ly(mtcars) %>% add_markers(x = ~wt, y = ~mpg) %>% layout( xaxis = list( title = 'Weight in kilograms (kg)' ), yaxis = list( title = 'Fuel eff
config
从模式栏中删除按钮,但它要么返回错误,要么在控制台中显示文本,而不对绘图本身进行更改:
myplot <- plot_ly(mtcars) %>%
add_markers(x = ~wt, y = ~mpg) %>%
layout(
xaxis = list(
title = 'Weight in kilograms (kg)'
),
yaxis = list(
title = 'Fuel efficiency (miles/gallon)'
)
)%>%
config(
displaylogo = FALSE,
collaborate = FALSE,
modeBarButtonsToRemove = c(
'sendDataToCloud', 'autoScale2d', 'resetScale2d', 'toggleSpikelines',
'hoverClosestCartesian', 'hoverCompareCartesian',
'zoom2d','pan2d','select2d','lasso2d','zoomIn2d','zoomOut2d'
)
)
对于我的实际用例,我将使用htmlwidgets::saveWidget()
将绘图保存为html文件。在上述示例中,modebar
在html文件和RStudio查看器中都可见
我检查了以下问题,但答案中的方法也不起作用(与我的示例代码相同):
会话信息:
> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 16299)
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] mailR_0.4.1 htmlwidgets_1.5.2 withr_2.3.0 rvest_0.3.6 xml2_1.3.2 httr_1.4.2
[7] jsonlite_1.7.1 plotly_4.9.2.1 ggplot2_3.3.2 lubridate_1.7.9 data.table_1.13.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 pillar_1.4.6 compiler_4.0.3 plyr_1.8.6 R.methodsS3_1.8.1 R.utils_2.10.1
[7] tools_4.0.3 digest_0.6.27 lifecycle_0.2.0 tibble_3.0.4 gtable_0.3.0 viridisLite_0.3.0
[13] pkgconfig_2.0.3 rlang_0.4.8 rstudioapi_0.11 crosstalk_1.1.0.1 yaml_2.2.1 curl_4.3
[19] rJava_0.9-13 stringr_1.4.0 dplyr_1.0.2 generics_0.0.2 vctrs_0.3.4 grid_4.0.3
[25] tidyselect_1.1.0 glue_1.4.2 R6_2.4.1 processx_3.4.4 purrr_0.3.4 tidyr_1.1.2
[31] magrittr_1.5 ps_1.4.0 scales_1.1.1 ellipsis_0.3.1 htmltools_0.5.0 colorspace_1.4-1
[37] stringi_1.5.3 lazyeval_0.2.2 munsell_0.5.0 crayon_1.3.4 R.oo_1.24.0
嗯,使用plotly 4.9.2.1,您的代码在我的机器上运行良好。我得到了一个仅在模式栏中显示“摄像头”的绘图图。@stefan这很奇怪,我运行的也是同一个版本。。我将把版本信息添加到问题中..嗨,Gautam。真奇怪。相同的R版本和几乎所有的软件包都与我的机器上的版本相同。唯一的区别是我的语言环境是德语。但是我很确定这不是问题所在。嗨,我用BaseR中的最小示例(但不是RStudio)实现了它。同样的方法不适用于我的实际示例,它有很多形状、注释等-我不认为其他痕迹/特征是失败的原因,但值得一试-我将尝试匿名我的数据并在这里共享实际的绘图代码。还计划在运行MacOS Mojave的不同设备上进行尝试,以确定这是否会产生影响。
> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 16299)
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] mailR_0.4.1 htmlwidgets_1.5.2 withr_2.3.0 rvest_0.3.6 xml2_1.3.2 httr_1.4.2
[7] jsonlite_1.7.1 plotly_4.9.2.1 ggplot2_3.3.2 lubridate_1.7.9 data.table_1.13.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 pillar_1.4.6 compiler_4.0.3 plyr_1.8.6 R.methodsS3_1.8.1 R.utils_2.10.1
[7] tools_4.0.3 digest_0.6.27 lifecycle_0.2.0 tibble_3.0.4 gtable_0.3.0 viridisLite_0.3.0
[13] pkgconfig_2.0.3 rlang_0.4.8 rstudioapi_0.11 crosstalk_1.1.0.1 yaml_2.2.1 curl_4.3
[19] rJava_0.9-13 stringr_1.4.0 dplyr_1.0.2 generics_0.0.2 vctrs_0.3.4 grid_4.0.3
[25] tidyselect_1.1.0 glue_1.4.2 R6_2.4.1 processx_3.4.4 purrr_0.3.4 tidyr_1.1.2
[31] magrittr_1.5 ps_1.4.0 scales_1.1.1 ellipsis_0.3.1 htmltools_0.5.0 colorspace_1.4-1
[37] stringi_1.5.3 lazyeval_0.2.2 munsell_0.5.0 crayon_1.3.4 R.oo_1.24.0