Home > Mobile >  How to plot comparison in Streamlit dynamically with multiselect?
How to plot comparison in Streamlit dynamically with multiselect?

Time:04-04

i created a comparison app with Streamlit and i want to compare it dynamically

Here's my code that i write

import streamlit as st
import matplotlib.pyplot as plt
import pandas as pd

    sampel_data={'Company':['A','B','C','D','E','F','G','H','I','J'],
                 'Profit':[3,4.5,2,2.5,1.25,3,3.25,5,6,2.75]}
    df_sampel=pd.DataFrame(data=sampel_data)
    st.dataframe(df_sampel)
    option1=st.multiselect("Choose company to compare",df_sampel)
    st.write(len(option1))
    fig,ax=plt.subplots()
    plt.bar(option1,height=10)
    st.pyplot(fig)

My problem is how to display profit because the x/horizontal part display correctly, but when display the y/vertical part, isn't displayed correctly.

CodePudding user response:

Your height parameter is wrong. Have a look here enter image description here

  • Related