简体   繁体   中英

Not able to display altair charts in jupyter notebook

I am not able to display the charts on jupyter notebook. The same code displays on chrome in one laptop but does not work on chrome on other laptop.

I do not see any error or even a empty plot when I execute the code but get alt.Chart(...) in the output.

The version of altair and vega etc are same on both the laptops.

If it works in one notebook and not another, there are a couple possibilities for what is going on:

  1. your notebooks are connected to different kernels with different versions of Altair and/or its dependencies installed. Run the following

    import sys print(sys.executable)

    to see if you're using the same Python executable in your environments. If the results are different, you can use Kernel -> Change Kernel in the Jupyter notebook menu to change to a kernel with a working Altair version.

  2. If that's not the case, then it is likely that you have inadvertently enabled a different renderer in one of the notebooks, for example by running alt.renderers.enable('notebook') . In Altair 4.0, the default renderer should work out-of-the-box in both Jupyter notebook and JupyterLab. Either restart your kernel or run alt.renderers.enable('default') to restore the default.

  3. The behavior above can happen if you have too old a version of IPython installed. See If the notebook displays on one laptop and not the other, it may be that the broken one has too old a version of IPython installed. See https://altair-viz.github.io/user_guide/troubleshooting.html#notebook-textual-chart-representation for more information on what to upgrade.

See Altair's Display Troubleshooting guide for more information.

对于 '4.1.0' 的 'altair' 版本,'3.4.0' 的 'vega' 版本只需执行alt.renderers.enable('default')而不是alt.renderers.enable('notebook')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM