graphs from Altair are not displaying

2019-05-21 01:14发布

问题:

On Ubuntu x64, I just freshly installed Anaconda 3.

I then installed altair via conda per these directions. Then I run the example code:

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

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

The code runs, but nothing happens. I expected a page would open in the browser perhaps, like bokeh does. To be safe, I also ran jupyter notebook in the background and re-running the code - no difference.

Please let me know if there's more information you need about my environment.

回答1:

Thanks to @cel, I found out the code cannot be run in the iPython console from Anaconda - it needs to be run from a Jupyter notebook.

You have to run jupyter notebook in the terminal, then create a new iPython Notebook. Once the notebook is created, you can run your code interactively from the notebook.