【发布时间】:2018-10-27 07:09:35
【问题描述】:
我想使用 altair 在 Jupyter notebook 中查看图表。所以我尝试了tutorial examples。我已经安装了所需的软件包。 这是我的代码:
import altair as alt
from vega_datasets import data
# Uncomment/run this line to enable Altair in the classic notebook
# (this is not necessary in JupyterLab)
alt.renderers.enable('notebook')
cars = data.cars()
chart = alt.Chart(cars).mark_circle().encode(
x='Horsepower',
y='Miles_per_Gallon',
color='Origin',
)
chart
我得到的是字典而不是图表。像这样:
Chart({
data: Acceleration Cylinders Displacement Horsepower Miles_per_Gallon \
0 12.0 8 307.0 130.0 18.0
1 11.5 8 350.0 165.0 15.0
2 11.0 8 318.0 150.0 18.0
3 12.0 8 304.0 150.0 16.0
使用此命令安装数据集时:
conda install -c conda-forge altair vega_datasets notebook vega3
这个错误可能是原因还是有其他问题?
【问题讨论】:
-
您是否按照此处的故障排除步骤进行操作? altair-viz.github.io/user_guide/…
标签: python python-2.7 jupyter-notebook vega-lite altair