I'm using a Databricks notebook. For various reasons, I need to render charts individually (concat doesn't give me the results I want) and I can't put the chart object at the end of the cell. I want to render each chart and do some processing. Here's some simple code that shows what I want to do.
import altair as alt
import pandas as pd
alt.renderers.enable('default')
df = pd.DataFrame({'x': [1,2,3,4,5],
'y1': [1,2,3,4,5],
'y2': [6,7,8,9,10]})
for y in ['y1', 'y2']:
chart = (alt.Chart(df, title="{0} vs x".format(y))
.mark_line()
.encode(x=alt.X('x:Q'),
y=alt.Y(y, title='Score')))
chart.display()
pass # More code that does stuff
Unfortunately, the output is:
alt.Chart(...)
alt.Chart(...)
I've tried vega version 2.2.0, 3.4.0, and 3.5.0 and I still get the same problem. I'm using altair version 4.1.0, IPython version 7.19.0, and Python 3.8.8.
I've tried different renderers ('mimetype', 'notebook') and I didn't get anything.
Does anyone know how to get the display() method working in Databricks?