plotly / plotly.R

An interactive graphing library for R
https://plotly-r.com
Other
2.56k stars 626 forks source link

New feature request: a modeBarButtonsToKeep argument in the config function #1740

Open davidhodge931 opened 4 years ago

davidhodge931 commented 4 years ago

Currently plotly has a function to remove listed mode bar buttons.

It'd be nice if it had a function to keep listed mode bar buttons, and to drop the rest.

Otherwise the code is quite long-winded if a user only wants to keep one button, such as the camera.

This argument could be called modeBarButtonsToKeep

library(dplyr)
library(ggplot2)

plot <- ggplot(iris) +
  geom_point(aes(Sepal.Width, Sepal.Length))

plotly::ggplotly(plot) %>% 
  plotly::config(modeBarButtonsToRemove = list("zoom2d", "pan2d", "zoomIn2d", "zoomOut2d", 
"autoScale2d","resetScale2d", "hoverClosestCartesian", "hoverCompareCartesian", 
"sendDataToCloud", "toggleHover", "resetViews", "toggleSpikelines", "resetViewMapbox", 
"toggleSpikelines", "resetViewMapbox", "lasso2d", "select2d"))
cpsievert commented 4 years ago

Great idea, might be worth requesting here as well https://github.com/plotly/plotly.js/issues/new

davidhodge931 commented 4 years ago

Just added it on plotly.js - thanks :)