Reputation: 3076
I have a bunch of HTML files that were made with using plotly and they have this cool interactivity. I cannot create the plots again, I only have access to the HTML files that were sent to me. I want to put all these plots in a single "page" (or whatever name it has) and add some text, but without loosing the interactivity, and finally create a standalone file with this "report". Is it possible? How?
In other words: When I receive the plots as PNG images I just create a PDF file with the plots and the text I want with any program like Word or Latex. Now I want to do the analogous but with plotly plots, but I don't want to create images from these plots and end up in a PDF, I want to keep them interactive and end up in some kind of "stand alone web page" that you can open with a browser.
Upvotes: 0
Views: 207
Reputation: 592
You can use iframe
to include HTML files generated by plotly. Find a minimal example below.
R code to generate index.html (source):
library(plotly)
set.seed(100)
d <- diamonds[sample(nrow(diamonds), 1000), ]
p <- d %>% plot_ly(x = ~carat, y = ~price, text = ~paste("Clarity: ", clarity),
+ mode = "markers", color = ~carat, size = ~carat)
htmlwidgets::saveWidget(as_widget(p), "index.html")
HTML to include index.html using the iframe
tag:
<!DOCTYPE html>
<html>
<body>
<h1>My Heading</h1>
<p>My paragraph.</p>
<iframe src="index.html" width = '500px' height = '300px'></iframe>
</body>
</html>
Upvotes: 1