I am trying to remove buttons from the modebar using config
but it either returns an error or displays text in the console with no change to the plot itself:
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'
)
)
modeBarButtonsToRemove
is based on the plotly GitHub page.
I've also tried defining the plot first and then using config
without any success:
myplot <- plot_ly() ...
config(myplot, ...)
For my actual use case, I will save the plots as html files using htmlwidgets::saveWidget()
. In the above examples the modebar
is visible in both the html files and also RStudio Viewer.
I've checked the following questions but the approach in the answers doesn't work either (same as my sample code):
- How can I customize the modebar in plotly (preferably in R)?
- How to custom or display modebar in plotly?
- How to disable the zoom of a plotly chart in R?
Session Info:
> 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