5

维护者注意:这个问题已经过时了。figure在自动组合上调用多个字形方法(并且已经使用了很多年)。有关现代散景的信息,请参阅:

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



过时的:

我正在 IPython 笔记本中运行 Bokeh 教程。它只显示散点图而不显示折线图。从命令行它分别呈现两个图。

如何在同一个图表中将两个图表放在一起?

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()
4

2 回答 2

3

过时的答案:请参阅https://docs.bokeh.org/en/latest/docs/user_guide/plotting.html * 了解现代散景



您只需要bplt.hold()在任何绘图命令之前调用,即可切换“保持状态”。以下代码适用于我:

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()
于 2014-03-22T06:16:58.367 回答
1

过时的答案:请参阅https://docs.bokeh.org/en/latest/docs/user_guide/plotting.html了解现代散景



尝试使用figure此示例中的命令:

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()
于 2013-12-11T20:57:28.893 回答