0

I have a VM running jupyterlab and have opened it up for external access. When jupyter-lab starts, a local browser opens up, which is fine.

Externally, I access jupyterlab and things appear to work. However, when I plot, the output doesn't show up in the browser but instead appears as a new tab in the local browser which started up with jupyter-lab.

The same thing happens if I have %matplotlib inline.

The following is a little better in that now things display inline. However, a new tab still opens up in the other browser.

%matplotlib inline
from bokeh.plotting import figure, show, output_notebook
from bokeh.sampledata.iris import flowers

output_notebook()

colormap = {'setosa': 'red', 'versicolor': 'green', 'virginica': 'blue'}
colors = [colormap[x] for x in flowers['species']]

p = figure(title = "Iris Morphology")
p.xaxis.axis_label = 'Petal Length'
p.yaxis.axis_label = 'Petal Width'

p.circle(flowers["petal_length"], flowers["petal_width"],
        color=colors, fill_alpha=0.2, size=10)

# output_file("iris.html", title="iris.py example")

show(p)
Robert Lugg
  • 1,090
  • 2
  • 12
  • 40

1 Answers1

0

The problem is not related to my setup but instead simply to my lack of understanding regarding Bokeh. Bokeh has state. So, if you call output_file() or maybe even if not, it saves all your plots which causes them to also display in a new browser tab. The solution is to not do that :)

Putting the following code at the top of the example cell above fixed the issue:

bokeh.io.reset_output()
bokeh.io.output_notebook()

I found the answer here. Thank you bigreddot and martin-martin

Technically, mine is a duplicate question. However it was non-obvious enough that I'll leave it around.

Robert Lugg
  • 1,090
  • 2
  • 12
  • 40