Removing the Edit Chart link from an R plotly graph

淺唱寂寞╮ 提交于 2019-11-30 13:32:01

问题


Is there a way to remove/hide the 'Edit Chart' link that appears in the bottom right half of your graph in the R version of Plotly?


回答1:


From the documentation, use config:

Plotly object p

p %>%
config(showLink = F)

You can see .js config options in action here.

Note: the "save and edit plot in cloud" button in the Mode Bar at the top still exists. You can turn off the Mode Bar with

config(displayModeBar = F)

There is a request on GitHub to edit specific Mode Bar buttons.




回答2:


Just to add to Sam's fix (thanks!), there is a typo, I had to use ...

 tags$head(
    tags$style(HTML('a[data-title="Save and edit plot in cloud"]{display:none;}'))
) 

Note the capital "S" on "Save.




回答3:


It can be done using CSS. Here an an example of it being done in a shiny application.

library(shiny)
library(plotly)
ui <- fluidPage( 
  tags$head(
    tags$style(HTML('a[data-title="save and edit plot in cloud"]{display:none;}'))
 ),
  plotlyOutput(outputId = "plot")
)

server <- function(input, output){
  output$plot <- renderPlotly({

plot_ly(type = "scatter",
        x = rnorm(10),
        y = rnorm(10),
        mode = "markers")
  })
}

shinyApp(ui, server)

I'm not sure how to remove it elsewhere or if there's an argument to turn it off, but this is how I do it.



来源:https://stackoverflow.com/questions/33499917/removing-the-edit-chart-link-from-an-r-plotly-graph

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!