Jibril
Jibril

Reputation: 1037

Python 3.6 - Altair Chart Prints Object, Not Graph

What can cause graph objects to not display the actual graph, but a chart? Reproducible example below.

from pydataset import data
import altair

cars = data('cars')

cars

c = altair.Chart(cars).mark_line().encode(
    x='speed',
    y='dist'
)

Outputs

Chart({
  data:     speed  dist
  1       4     2
  2       4    10
  3       7     4
  4       7    22
  5       8    16
...
encoding: FacetedEncoding({
    x: X({
      shorthand: 'speed'
    }),
    y: Y({
      shorthand: 'dist'
    })
  }),
  mark: 'line'
})

Expected output is a graph, such as the one shown here https://altair-viz.github.io/user_guide/troubleshooting.html#display-troubleshooting

Obviously I've read the trouble shooting, but it isn't clear to me this problem. They talk about getting no output, but not about getting the object as an output.

Edit to clarify : They DO talk about that, but specifically if using Jupyter Notebook and IPython being underversioned. I have Jupyter installed, but am not using. I have IPython installed, but not underversioned.

Upvotes: 1

Views: 279

Answers (1)

jakevdp
jakevdp

Reputation: 86328

I have Jupyter installed, but am not using.

If you are not using Jupyter notebook. JupyterLab, or a similar notebook environment, then you will need some other Javascript-enabled frontend in which to render your charts. You can find more information on this at https://altair-viz.github.io/user_guide/display_frontends.html#display-general.

Upvotes: 1

Related Questions