INNER CODE UNIT · Python

_plot_jupyter_inline

briscverse/ryp · ryp.py:641

                    def _plot_jupyter_inline(*_: Any) -> None:
                        """
                        If the user just ran a cell that created a plot in R,
                        display it. Executed after each cell is run in the
                        Jupyter notebook.
                        """
                        # If temp_file doesn't exist, nothing's been plotted in
                        # this cell
                        if not os.path.exists(temp_file):
                            return
                        # Save the plot to temp_file in R
                        r('dev.off()')
                        # Load the plot from temp_file into Python, as a
                        # bytestring
                        with open(temp_file, 'rb') as file:
                            data = file.read()
                        # Display the plot in the Jupyter notebook
                        display(SVG(data=data))

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…