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
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.
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.