Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embedding a plotly html figure #159

Closed
dktanwar opened this issue Aug 6, 2018 · 3 comments
Closed

Embedding a plotly html figure #159

dktanwar opened this issue Aug 6, 2018 · 3 comments

Comments

@dktanwar
Copy link

dktanwar commented Aug 6, 2018

I am trying to embed a html figure into xaringan presentation:

  1. This works perfectly fine
library(plotly)
p <- plot_ly(z = volcano, type = "heatmap")
p

Save the figure:

htmlwidgets::saveWidget(p, paste0("p.html"))
  1. This does not work at all"
htmltools::knit_print.html("p.html")

Not even this:

htmltools::knit_print.shiny.tag("p.html")
@tcgriffith
Copy link
Collaborator

tcgriffith commented Aug 8, 2018

The saved htmlwidget is a complete html file with its own , sections etc, while print(p) will produce a

section in the slides. My suggestion is to stick with method 1.

If you feel like to save the plot, save it as a normal R object using:

save(p, file ="p.rda")

and load & redraw it later, using

library(plotly)
load("p.rda")
p

@dktanwar
Copy link
Author

After trying a lot of options, I wonder if there is any option for it yet.

@dktanwar
Copy link
Author

Found a way: rstudio/htmltools#90

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants