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.
- Listing legend items horizontally and centered below a plot
- https://statisticsglobe.com/customize-legend-plotly-graph-r
- https://plotly.com/r/legend/
- How can I hide a trace in a legend in R plotly
- https://search.r-project.org/CRAN/refmans/plotly/html/hide_legend.html
- https://plotly.com/r/discrete-color/
- Change legend size in plotly chart
- https://statisticsglobe.com/change-colors-plotly-graph-r