I have having significant difficulty with plotly in R. The code below produces a blank plot, even though calling ‘p’ without the ggplotly produces a plot. I have uninstalled and reinstalled both R and RStudio but the problem persists.
library(plotly)
library(ggplot2)
data(mtcars)
p <- ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point()
ggplotly(p)
I have tried several possible fixes. R, RStudio, and plotly are all the latest versions: R 4.4.0, RStudio 2024.04.1, plotly 4.10.4.
The code below will produce a plot on a separate page in the web browser:
plot <- plot_ly(data = mtcars, x = ~wt, y = ~mpg, type = ‘scatter’, mode = ‘markers’)
htmlwidgets::saveWidget(plot, “test_plot.html”)
browseURL(“test_plot.html”)
Erik Jensen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.