File size: 2,244 Bytes
6585a27
 
a346046
 
6585a27
a346046
 
6585a27
a346046
 
 
6585a27
a346046
 
 
6585a27
a346046
 
 
6585a27
a346046
 
6585a27
a346046
 
 
6585a27
a346046
 
 
 
6585a27
a346046
 
 
 
6585a27
a346046
 
 
 
6585a27
a346046
 
 
 
6585a27
a346046
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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()