Empty Code Blocks showing up on the interface

Hi, just started working with streamlit and I’ve got a problem with empty spaces showing up on the app pages. I can only imagine it’s coming from inside the functions I’m calling but not sure what to do. I’m working in VSCode and calling functions to display plotly graphs like this:

def ageRange():
    # ages = df.iloc[:,4].value_counts().sort_values(ascending = True)
    # Q4 Pie chart

    # set plot size
    plt.rcParams['figure.figsize'] = [6,6]

    # Creating font properties using fontdict
    font = {'family':'Baskerville', 'color':'black', 'size':24} 

    labels = ['NA','Pre-school', 'Secondary School', 'Primary School', 'All Ages']
    sizes = [1, 5, 10, 85, 99]

    colours = ['#35193e', '#f37651', '#ad1658','#701f58', '#e13442' ]

    explode = (0.01, 0.1, 0.1, 0.02, 0.02)

    # function to hide label if percent below 2 e.g for NA 
    def my_autopct(pct):
        return ('%1.1f%%' % pct) if pct > 2 else ''

    fig3, ax3 = plt.subplots()
    patches, texts, autotexts = ax3.pie(sizes, colors = colours, labels=labels, autopct=my_autopct, startangle = 90, pctdistance = 0.85, explode = explode)
    # change label colours
    [text.set_color('black') for text in texts]
    [text.set_size(9) for text in texts]
    [autotext.set_color('white') for autotext in autotexts]
    [autotext.set_size(8)for autotext in autotexts]

    # draw circle: drawing a circle centered at (0,0)
    centre_circle=plt.Circle((0,0), 0.70, fc ='white')
    fig3 = plt.gcf()

    # Equal aspect ratio to make sure pie is drawn as a circle

    # Add title
    ax3.set_title("Proportions of Age Ranges experiencing Anxiety",fontdict = font, x=.45, y = .94)

elif options == 'Ages Affected':
    # app layout 
    st.markdown("Of 2

Should I be nesting this function somehow? Not sure that plotly will catch the plots and axes if I start doing that. Any help appreciated.

This is what it looks like on the app

Hi @Aisling ,

Assuming you are referring the to empty lists with NULL inside, please check this part of your code. You have 4 list comprehensions, but you are stating them and not assigning them to a variable, so Streamlit will interpret that you want to render them.

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