Altair 的图表未显示

graphs from Altair are not displaying

在 Ubuntu x64 上,我刚刚安装了 Anaconda 3。

然后我根据 these directions 通过 conda 安装了 altair。然后我运行示例代码:

from altair import *
population = load_dataset('population')

Chart(population).mark_bar().encode(
    x='sum(people)',
).transform_data(filter="datum.year==2000")

代码 运行s,但没有任何反应。我预计页面可能会在浏览器中打开,就像 bokeh 那样。为了安全起见,我还在后台 运行 jupyter notebook 并重新 运行 代码 - 没有区别。

如果您需要有关我的环境的更多信息,请告诉我。

感谢@cel,我发现代码不能在 Anaconda 的 iPython 控制台中 运行 - 它需要来自 Jupyter notebook 的 运行。

您必须在终端中 运行 jupyter notebook,然后创建一个新的 iPython 笔记本。创建笔记本后,您可以从笔记本中以交互方式运行编写代码。