问题
I was hoping to use plotly::ggplotly()
to plot a graph produced with ggtern()
with a tooltip feature. But loading the package ggtern caused ggplotly to throw the following error:
Error in inherits(theme[[element]], ggplot_global$element_tree[[element]]$class) : 'what' must be a character vector
What's more, this error appears for all graphs, not just those produced by ggtern.
Here is an example.
library(ggplot2)
# This works
gg.mtcars <- ggplot(mtcars, aes(hp, mpg)) +
geom_point()
plotly::ggplotly(gg.mtcars)
library(ggtern)
data("Feldspar")
gg.feldspar <- ggtern(data = Feldspar, aes(x = Ab, y = An, z = Or)) +
geom_point()
# This throws an error
plotly::ggplotly(gg.feldspar)
# And now this throws an error too
plotly::ggplotly(gg.mtcars)
来源:https://stackoverflow.com/questions/56083771/why-does-ggplotly-break-when-ggtern-is-loaded