0

I created a plot related to the electric vehicle market in Austria:

https://gibraltar.shinyapps.io/esim-v2/

For this I've used shiny for hosting as a WebApp and plotly for the general plotting.

My problem is that I can't remove the legend (ePCM) on the right side.

This is the server side of my code (shiny and plotly syntax).

# Define the server logic
server <- function(input, output) {
  # Filter data based on selected car model
  filteredData <- reactive({
    if (input$carModel == "Alle") {
      dataSelection
    } else {
      dataSelection[dataSelection$CompleteModelName == input$carModel, ]
    }
  })
  
  # Render the plotly plot
  output$plot <- renderPlotly({
    evPlot <- plot_ly(
      data = filteredData(), x = ~Reichweitenkosten, y = ~RLL,
      text = ~CompleteModelName,
      color = ~ePCM, size = ~ePCM,
      type = "scatter", mode = "markers"
    )
    
    # Update x-axis and y-axis range to keep them fixed
    evPlot <- evPlot %>% layout(
      xaxis = list(range = c(min(dataSelection$Reichweitenkosten), max(dataSelection$Reichweitenkosten)*1.1)),
      yaxis = list(range = c(min(dataSelection$RLL), max(dataSelection$RLL)*1.1))
    )
    
    evPlot
    
  })
}

Could you please help my out?

Among many others I tried the solutions from those links. I just couldn't remove the legend.

Gibraltar
  • 1
  • 2

1 Answers1

0

After browsing for hours I've found the solution:

https://stackoverflow.com/a/61088212/21629420

Adding %>% hide_colorbar() did the trick. ♥

Gibraltar
  • 1
  • 2