1

Based on this question I would like to also change the background color of the modebar when hovering over it. I looked in the css, but couldn't find or change the relevant part.

Here's a small shinyApp to test around:

library(shiny)
library(plotly)

ui <- fluidPage(
  plotlyOutput("plotly")
)

server <- function(input, output, session) {
  output$plotly <- renderPlotly({
    plot_ly(data = mtcars) %>% 
      add_markers(x=~mpg, y=~disp) %>% 
      layout(plot_bgcolor='transparent', paper_bgcolor='transparent')
  })
}

shinyApp(ui, server)
SeGa
  • 9,454
  • 3
  • 31
  • 70

2 Answers2

1

I made it transparent but then the options are also invisible so I added a color and activecolor, see here. Feel free to change as necessary.

library(shiny)
library(plotly)

ui <- fluidPage(
    plotlyOutput("plotly")
)

server <- function(input, output, session) {
    output$plotly <- renderPlotly({
        plot_ly(data = mtcars) %>% 
            add_markers(x=~mpg, y=~disp) %>% 
            layout(plot_bgcolor='transparent', paper_bgcolor='transparent', 
                   modebar=list(bgcolor='transparent', color='blue', activecolor='green'))
    })
}

shinyApp(ui, server)
Eli Berkow
  • 2,628
  • 1
  • 12
  • 22
0
Referencia = [https://plotly.com/javascript/reference/layout/#layout-modebar][1]
 layout = {
title: '',
modebar: {
   orientation: 'h',
  bgcolor: '#ffffff',
  color:'red',
  activecolor:'red',
  position: 'left'
}}

enter image description here

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 11 '23 at 21:21