How to build (built-in) with rpy2 in a Jupyter laptop?

I am studying the use of rpy2 in a Jupyter laptop. I have problems with the plot. When I use this example from rpy2 docs for interactive work:

from rpy2.interactive import process_revents
from rpy2.robjects.packages import importr
from rpy2.robjects.vectors import IntVector
process_revents.start()

graphics = importr("graphics")
graphics.barplot(IntVector((1,3,2,5,4)), ylab="Value")

Jupyter opens a new plot window. The title window reads: R Graphics: Device 2 (ACTIVE) (not responding). The core of the Jupyter is active. When I try to close the window with the plot, the windows claim that python.exe is not responding, and if I force close, the jupyter kernel starts.

First: how can I make an rpy2 graph in a row? Secondly: if the built-in build is not possible, how to get the plot in a window without python.exe, stops responding?

+4
1

, : https://bitbucket.org/rpy2/rpy2/issues/330/ipython-plotting-wrapper

with rpy2.robjects.lib.grdevices.render_to_bytesio(grdevices.png, width=1024, height=896, res=150) as img:
    graphics.barplot(IntVector((1,3,2,5,4)), ylab="Value")
IPython.display.display(IPython.display.Image(data=img.getvalue(), format='png', embed=True))
+2

Source: https://habr.com/ru/post/1673568/


All Articles