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

ggplotly does not render in Jupyter #398

Closed
rcrezende opened this issue Jan 15, 2016 · 4 comments
Closed

ggplotly does not render in Jupyter #398

rcrezende opened this issue Jan 15, 2016 · 4 comments

Comments

@rcrezende
Copy link

When executing the following in the Jupyter Notebook no plot is returned.

library(plotly)

dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
qplot(carat, price, data=dsamp, colour=clarity)

ggplotly()

Is there any plan on supporting Jupyter?

@cpsievert
Copy link
Collaborator

This is a known limitation of the htmlwidgets framework -- ramnathv/htmlwidgets#144

@millermd69
Copy link

I am new to plotly. I attempted to use the embed_notebook() function but an error was generated
Error in embed_notebook(pp): x must be a plotly figure

library(plotly)
p <- ggplot(data = diamonds, aes(x = cut, fill = clarity)) +
            geom_bar(position = "dodge")
pp <- ggplotly(p)
embed_notebook(pp)

Shouldn't this function render the interactive graph in Jupyter?

@cpsievert
Copy link
Collaborator

Thanks for pointing that out @millermd69, #409 fixes that error.

PS. unless htmlwidgets provides "native" support for Jupyter, I think the best we can do is save each plot to disk and embed as an <iframe>. Unfortunately, that means the HTML files will reside on disk after exiting the notebook, as I'm not sure of a good way to clean up those files upon exit. If anyone has a better solution, I'm all ears!

@randy3k
Copy link

randy3k commented Sep 1, 2016

with the latest plotly, htmlwidgets, jupyter and iRkernel, the follow works.

library(plotly)

dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
p <- qplot(carat, price, data=dsamp, colour=clarity)
as.widget(ggplotly(p))

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

4 participants