官网:https://altair-viz.github.io/faq.html
The most common cause of a non-displaying plot in the Jupyter Notebook is incorrect configuration of the ipyvega jupyter extension, which is what recognizes an Altair object and automatically renders the plot with the Vega-Lite library.
If you install altair using conda
, this nbextension setup step should be taken care of automatically. If you install altair using pip
, there is an extra step to enable this extension; see the discussion at .
If this still is not addressing the problem, it may be due to having multiple incompatible versions of altair and vega on your system. Try updating both packages using, e.g. conda update altair vega
or pip install altair vega --update
.
If this still doesn’t work, please open an issue in the Altair’s , and we will do our best to help. In the meantime, other means of displaying Altair plots are listed in .
考虑安装命令:(保证以下三个命令都在Prompt黑框端有效安装)
Altair can be installed via the Python Package Index with the following:
$ pip install altair$ pip install --upgrade notebook$ jupyter nbextension install --sys-prefix --py vega
The additional commands serve to set-up the module to automatically render Altair plots within the Jupyter notebook (see ) Alternatively, you can install with , which handles the Jupyter notebook setup within the single install command:
$ conda install altair --channel conda-forge