gpt4 book ai didi

python - Altair 的图表未显示

转载 作者:太空宇宙 更新时间:2023-11-04 00:47:55 25 4
gpt4 key购买 nike

在 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")

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

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

最佳答案

感谢@cel,我发现代码无法在 Anaconda 的 iPython 控制台中运行 - 它需要从 Jupyter notebook 运行。

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

关于python - Altair 的图表未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38535357/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com