Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display chart in PyCharm / IPython #1516

Closed
addisonklinke opened this issue May 17, 2019 · 1 comment
Closed

Display chart in PyCharm / IPython #1516

addisonklinke opened this issue May 17, 2019 · 1 comment
Labels

Comments

@addisonklinke
Copy link

addisonklinke commented May 17, 2019

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
@addisonklinke addisonklinke changed the title Display chart in PyCharm / iPython Display chart in PyCharm / IPython May 17, 2019
@jakevdp
Copy link
Collaborator

jakevdp commented May 17, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants