Closed
Description
FYI, future changes in ggplot2
will break ggplotly()
. The following example did not work with the development version of ggplot2
.
See also this discussion
library(dplyr)
library(ggplot2)
packageVersion("ggplot2")
#> [1] '3.4.2.9000'
data("airquality")
airquality <- airquality %>%
select(Month, Day, Temp) %>%
mutate(Date = as.Date(paste("1973", Month, Day, sep = "-")))
plt1 <- ggplot(airquality,
aes(x = Date,
y = Temp)) +
geom_line() +
theme_bw()
library(plotly)
packageVersion("plotly")
#> [1] '4.10.1'
ggplotly(plt1,
tooltip = c("x", "y", "color", "text"),
dynamicTicks = TRUE) %>%
rangeslider() %>%
layout(
legend = list(orientation = "h", x = 0.1, y = -0.5)
)
#> Error in match.fun(FUN): 'ggfun("scales_transform_df")' is not a function, character or symbol
https://github.com/plotly/plotly.R/blob/master/R/ggplotly.R#L317
# Transform all scales
data <- lapply(data, ggfun("scales_transform_df"), scales = scales)
https://github.com/plotly/plotly.R/blob/master/R/ggplotly.R#L1391-L1395
# We need access to internal ggplot2 functions in several places
# this helps us import functions in a way that R CMD check won't cry about
ggfun <- function(x) {
tryCatch(getFromNamespace(x, "ggplot2"), error = function(e) NULL)
}
Metadata
Metadata
Assignees
Labels
No labels