Altair plots showing up as blank webpage

Ask the community or our support engineers for answers to questions.
Hello All,
I am new to streamlit and today while working on a Altair dashboard, I tried to plot some basic Altair charts first using my terminal prompt and then within jupyter notebook to test it out. However, both instances resulted in a blank output.

The code I used, was from the Altair visualization library.

%%writefile app.py
import altair as alt
import pandas as pd

def source():

  df = pd.DataFrame({'a': ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'],
                         'b': [28, 55, 43, 91, 81, 53, 19, 87, 52]})
  plot = (alt.Chart(df)
          .mark_bar()
          .encode(x='a',
                  y='b'))         
  return plot 

if __ name __ == ‘__ main __’:

source()

Input:
Terminal: streamlit run source.py
Output : Blank webpage

Jupyter : st.altair(source(), use_container_width=False)
Output: DeltaGenerator(_root_container=0, _provided_cursor=None, _parent=None, _block_type=None, _form_data=None)

Version:
Python 3.9.7
Streamlit 1.9.0

I am not sure what might be causing this and will appreciate some help. Thanks!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.