File size: 1,552 Bytes
2564989
 
 
 
 
 
 
f695738
2564989
 
 
 
 
 
 
 
 
 
 
 
f695738
 
2564989
 
 
 
 
 
 
 
f695738
 
2564989
 
f695738
2564989
 
5fb253c
2564989
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198720a
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
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

# Function to plot a bar chart
def plot_bar_chart(df):
    plt.figure(figsize=(8, 6))
    sns.barplot(x='Category', y='Value', data=df)
    plt.title('Category vs Value')
    plt.xlabel('Category')
    plt.ylabel('Value')
    plt.tight_layout()
    return plt

# Function to plot a line chart
def plot_line_chart(df):
    plt.figure(figsize=(8, 6))
    sns.lineplot(x='Category', y='Value', data=df)
    plt.title('Category vs Value')
    plt.xlabel('Category')
    plt.ylabel('Value')
    plt.tight_layout()
    return plt

# Function to plot a pie chart
def plot_pie_chart(df):
    plt.figure(figsize=(8, 6))
    df.set_index('Category')['Value'].plot.pie(autopct='%1.1f%%', figsize=(8, 6))
    plt.title('Category Distribution')
    return plt

# Streamlit interface
st.title('Advanced Data Visualization App')

# Upload CSV file
uploaded_file = st.file_uploader("Upload your CSV file", type=["csv"])

if uploaded_file is not None:
    # Load CSV into a pandas DataFrame
    df = pd.read_csv(uploaded_file)
    
    # Display the dataframe
    st.write(df)

    # Chart type selection
    chart_type = st.selectbox('Select the chart type:', ['Bar Chart', 'Line Chart', 'Pie Chart'])
    
    # Plot based on selected chart type
    if chart_type == 'Bar Chart':
        st.pyplot(plot_bar_chart(df))
    elif chart_type == 'Line Chart':
        st.pyplot(plot_line_chart(df))
    elif chart_type == 'Pie Chart':
        st.pyplot(plot_pie_chart(df))