Altair: Display chart in PyCharm / IPython

Created on 17 May 2019  路  1Comment  路  Source: altair-viz/altair

I'd like to use altair in PyCharm so that I can edit source code in the IDE, execute it in the built-in IPython console, and view plots in a separate window. From my understanding, IPython was the precursor to Jupyter notebooks so this should be possible.

Using the getting started example

import altair as alt

alt.renderers.enable('notebook')
cars = alt.load_dataset('cars')
alt.Chart(cars).mark_point().encode(
    x='Horsepower',
    y='Miles_per_Gallon',
    color='Origin',
).interactive()

At first, I got an error from alt.renderers.enable('notebook'), but this was solved by installing vega and notebook per the troublshooting guide here. However, after that fix I still cannot view the plot. My IPython output is simply <vega.vegalite.VegaLite at 0x7f539d7e6c18> regardless of whether the .interactive() extension is used at the end of the command.

Is there a method similar to plt.show() that I'm missing, or is altair incompatible with visualizing in this PyCharm / IPython setup?

Details

  • IPython version 7.5.0
  • PyCharm CE 2019.1
  • Ubuntu 18.04
question

Most helpful comment

Take a look at https://altair-viz.github.io/user_guide/faq.html#does-altair-work-with-pycharm-spyder-my-favorite-ide

I've also recently updated the display docs with more information about this use-case. It's not made it into the website yet, but you can read the source version here: https://github.com/altair-viz/altair/blob/master/doc/user_guide/display_frontends.rst#working-in-non-notebook-environments

In particular, the vegascope approach is pretty useful when working in the IPython terminal.

>All comments

Take a look at https://altair-viz.github.io/user_guide/faq.html#does-altair-work-with-pycharm-spyder-my-favorite-ide

I've also recently updated the display docs with more information about this use-case. It's not made it into the website yet, but you can read the source version here: https://github.com/altair-viz/altair/blob/master/doc/user_guide/display_frontends.rst#working-in-non-notebook-environments

In particular, the vegascope approach is pretty useful when working in the IPython terminal.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

morberg picture morberg  路  3Comments

dzonimn picture dzonimn  路  3Comments

maxgerma picture maxgerma  路  3Comments

firasm picture firasm  路  3Comments

tonylee3399 picture tonylee3399  路  3Comments