Using RStudio's viewer to display HTML plots from the terminal (python)

viewer
python

#1

Hi everyone,

With the current support for python syntax in the editor, a terminal that can run python or ipython and an easy keyboard shortcut to send code from the editor to the terminal, RStudio is actually a decent python development environment (and projects, RStudio server, etc. are advantages that are difficult to find in actual python IDEs).

A main roadblock I am hitting now is how to display plots from python, in particular remotely, from python running in a terminal in RStudio server. Beyond matplotlib, many python plotting libraries output HTML plots (plotly, bokeh, etc.). Those should be displayable in RStudio's viewer. Does anyone have a clue how to achieve that?

PS: I know about reticulate but I need to stay full python in this case, for collaboration purposes.

A bit of bokeh code as a test:

# prepare some data
x = [1, 2, 3, 4, 5]
y = [6, 7, 2, 4, 5]

# import bokeh
from bokeh.plotting import figure, show, output_notebook, output_file

# output to static HTML file
output_file("foo.html")
# output_notebook() # for jupyter notebooks

# create a new plot
p = figure()
# add a line renderer with legend and line thickness
p.line(x, y, legend="Bar", line_width=2)
# show the results
show(p)

Thanks in advance. Sincerely,

Jean-Olivier Irisson
Sorbonne Université
Laboratoire d'Océanographie de Villefranche
http://obs-vlfr.fr/~irisson/


#2

This would certainly be possible, but it's not implemented quite yet. Could you file a feature request on our GitHub issues page? https://github.com/rstudio/rstudio/issues


#3

Done: https://github.com/rstudio/rstudio/issues/3404