import streamlit as st import pandas as pd import seaborn as sns import matplotlib.pyplot as plt # Load the Iris dataset iris_df = sns.load_dataset('iris') # Sidebar for file upload and dataset selection st.sidebar.title('Upload CSV File') uploaded_file = st.sidebar.file_uploader("Choose a CSV file", type=['csv']) if uploaded_file is not None: # Read the uploaded file custom_df = pd.read_csv(uploaded_file) # Display the uploaded dataset st.write('**Uploaded Dataset:**') st.write(custom_df.head()) # Sidebar for plot selection plot_type = st.sidebar.selectbox('Select Plot Type', ['Histogram', 'Scatter Plot']) if plot_type == 'Histogram': # Sidebar for selecting column selected_column = st.sidebar.selectbox('Select Column for Histogram', custom_df.columns) # Plot histogram plt.figure(figsize=(8, 6)) sns.histplot(custom_df[selected_column]) st.pyplot() elif plot_type == 'Scatter Plot': # Sidebar for selecting columns x_axis = st.sidebar.selectbox('Select X-Axis Column', custom_df.columns) y_axis = st.sidebar.selectbox('Select Y-Axis Column', custom_df.columns) # Plot scatter plot plt.figure(figsize=(8, 6)) sns.scatterplot(x=x_axis, y=y_axis, data=custom_df) st.pyplot() else: # Display the default dataset st.write('**Default Dataset (Iris):**') st.write(iris_df.head()) # Sidebar for plot selection plot_type = st.sidebar.selectbox('Select Plot Type', ['Histogram', 'Scatter Plot']) if plot_type == 'Histogram': # Sidebar for selecting column selected_column = st.sidebar.selectbox('Select Column for Histogram', iris_df.columns) # Plot histogram plt.figure(figsize=(8, 6)) sns.histplot(iris_df[selected_column]) st.pyplot() elif plot_type == 'Scatter Plot': # Sidebar for selecting columns x_axis = st.sidebar.selectbox('Select X-Axis Column', iris_df.columns) y_axis = st.sidebar.selectbox('Select Y-Axis Column', iris_df.columns) # Plot scatter plot plt.figure(figsize=(8, 6)) sns.scatterplot(x=x_axis, y=y_axis, data=iris_df) st.pyplot()