Question

Maintainers note: this question is obsolete. Calling multiple glyph methods on a figure automatically combines (and has for many years). For information on modern Bokeh, see:

https://docs.bokeh.org/en/latest/docs/user_guide/plotting.html



OBSOLETE:

I am running the Bokeh tutorial in the IPython notebook. It only displays the scatter plot and not the line plot. From the command-line it renders both plots separately.

How do I get both graphs in the same chart, on top of each other?

import numpy as np
import bokeh.plotting as bplt
bplt.output_file("bokehtest.html")
#bplt.output_notebook(url=None)
x = np.linspace(-2*np.pi, 2*np.pi, 100)
y = np.cos(x)
bplt.line(x, y, color="red")
bplt.scatter(x, y, marker="square", color="blue")
bplt.show()

No correct solution

OTHER TIPS

OBSOLETE ANSWER: see https://docs.bokeh.org/en/latest/docs/user_guide/plotting.html* for modern Bokeh



You just need to call bplt.hold() before any of the plotting commands, to toggle the "hold state". The following code works for me:

import numpy as np
import bokeh.plotting as bplt
bplt.output_file("bokehtest.html")
#bplt.output_notebook(url=None)
x = np.linspace(-2*np.pi, 2*np.pi, 100)
y = np.cos(x)
bplt.hold()  # <--- The important line!!
bplt.line(x, y, color="red")
bplt.scatter(x, y, marker="square", color="blue")
bplt.show()

OBSOLETE ANSWER: see https://docs.bokeh.org/en/latest/docs/user_guide/plotting.html for modern Bokeh



Try using the figure command like in this example:

import numpy as np
import bokeh.plotting as bplt
bplt.output_file("bokehtest.html")
x = np.linspace(-2*np.pi, 2*np.pi, 100)
y = np.cos(x)

bplt.figure()
bplt.line(x, y, color="red")
bplt.scatter(x, y, marker="square", color="blue")
bplt.show()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top