Black Lives Matter. Please consider donating to Black Girls Code today.

Jupyter not displaying plotly (python) or embedded plot_ly (R)

There’s a number of issues at play, but :

I have native R functions that I’m generating plotly charts for, in the context of a larger jupyter notebook for which the main language is python. I have coded the plotly functions for this in python, and tried the equivalent code in R (wrapped up in rmagic). I’ve also tried the code for both in their native IDEs (spyder, rstudio) and work fine.

  1. Using the python code, a blank canvas is printed in place of the plot, but on previous attempts, the plot appears fine (inconsistent)
  2. Using jupyter rmagic, no plot is displayed (not even a blank canvas). “print§” returns nothing either, but p is of type “list”.
  3. Under a native R kernel, a simple example scatter plot works.

I’m happy to run this all in python if someone could tell me how I can consistently display the plots, but if not, Can I run the R plot_ly function within jupyter cell magic?

Have you tried using IRKernel instead of R Magic?
https://irkernel.github.io/installation/
More info:

yes, that seems to work (see point 3), with R functions plotted using plot_ly. My only issue with using IRKernel is that the bulk of the code is Python, with little snippets of R used as necessary, and I was hoping to present the entire project in one location. Having two notebooks instead of one is not the end of the world. Strangely (for me), when it comes to plotly I prefer the R syntax over python, it seems cleaner and more concise.