-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
Hi tidyverse guys!
I think I found a bug in the new ggplot2 version, after updating to 4.0.0, when used in conjunction with plotly. Reverting to 3.5.2 gives no error, so I guess it's a new bug. It occurs when running ggplotly on a (apparently) working gg object, giving:
Error in pm[[2]] : subscript out of bounds
Here's the code giving the error:
library(sf)
library(ggplot2)
df <- data.frame(
Stazione = c("Station1", "Station2"),
Ora = c("12:00", "15:30"), # keep as HH:MM
color_val = c("red", "blue"),
Longitudine = c(9.1900, 9.2000),
Latitudine = c(45.4642, 45.4700)
)
# Convert to sf
df <- st_as_sf(df, coords = c("Longitudine", "Latitudine"), crs = 4326)
# Plot
gg <- ggplot() +
geom_sf(
data = df,
aes(
text = paste("Stazione:", Stazione, "<br>Ora:", Ora), # use Ora directly
customdata = Stazione
),
color = report_date_sf$color_val, size = 2, shape = 2
) +
theme_minimal()
gg
ggplotly(gg, tooltip = "text", source = "station_map")
Metadata
Metadata
Assignees
Labels
No labels