3

I've created an interactive plotly chart with plotly() in R and I'd like to save it as a file.

I'm okay with it being in any format, whether that's js or html or something else. I want to keep the interactivity.

This is my code

gg <-
   iris %>%
   ggplot(aes(Species, Sepal.length)) +
   geom_col(fill = "green")

ggplotly(gg)

I read on this answer that you can do plotly.offline.plot(data, filename='file.html') in the Python implementation for Plotly. My goal is to upload the plotly chart to a Notion document using the "upload file" functionality.

1 Answer 1

3

You can try with saveWidget() from htmlwidgets package:

library(plotly)
library(tidyverse)
library(htmlwidgets)
#Plot
gg <-
  iris %>%
  ggplot(aes(Species, Sepal.Length)) +
  geom_col(fill = "green")
#Export
saveWidget(ggplotly(gg), file = "myplot.html")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.