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()
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With