altair: Chart doesn't display, despite Mime representation enabled

I have an issue similar to #809 and the solution described didn’t work for me. Matplotlib can plot in Jupyter notebook. (I am using Jupyter notebook because Jupyter lab renders an empty page, or a page with only navigation headings, depending on the browser).

I use:

import altair as alt
from vega_datasets import data

alt.renderers.enable('notebook')
iris = data.iris()

alt.Chart(iris).mark_point().encode(
    x='petalLength',
    y='petalWidth',
    color='species'
)

and the output is empty: Out [1]:

Other tests that I ran are:

import sys
print(sys.version)
# 3.7.3 (default, Mar 27 2019, 09:23:15) 
# [Clang 10.0.1 (clang-1001.0.46.3)]
print(sys.executable)
# /usr/local/opt/python/bin/python3.7

class Test(object):
    def _repr_mimebundle_(self, include, exclude):
        return {'text/plain': "Mimebundle Repr"}
    def __repr__(self):
        return "Normal Repr"
    
Test()
# Mimebundle Repr

import IPython
IPython.__version__
# '7.5.0'

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 27 (13 by maintainers)

Most upvoted comments

Jupyter Lab is the recommended environment for Altair. Unfortunately, the JupyterLab release schedule is pretty drawn-out. We’re trying to take steps to mitigate this kind of mismatch in the future, but it’s pretty difficult given the constraints that the Jupyter ecosystem puts on any project that requires frontend extensions.