File size: 1,337 Bytes
247353b
 
 
 
 
1a2e8d6
247353b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

st.title("Palmer's Penguins Demo")
st.markdown("Use this Streamlit app to make your own scatterplot about penguins!")
st.markdown("Example from: [Getting Started with Streamlit for Data Science: Create and deploy Streamlit web applications from scratch in Python](https://www.packtpub.com/en-us/product/getting-started-with-streamlit-for-data-science-9781800565500)")

selected_x_var = st.selectbox(
    "What do want the x variable to be?",
    ["bill_length_mm", "bill_depth_mm", "flipper_length_mm", "body_mass_g"],
)
selected_y_var = st.selectbox(
    "What about the y?",
    ["bill_depth_mm", "bill_length_mm", "flipper_length_mm", "body_mass_g"],
)

# penguin_file = st.file_uploader('Select Your Local Penguins CSV')
# if penguin_file is not None:
# 	penguins_df = pd.read_csv(penguin_file)
# else:
# 	st.stop()
penguins_df = pd.read_csv("penguins.csv")

sns.set_style("darkgrid")
markers = {"Adelie": "X", "Gentoo": "s", "Chinstrap": "o"}
fig, ax = plt.subplots()
ax = sns.scatterplot(
    data=penguins_df,
    x=selected_x_var,
    y=selected_y_var,
    hue="species",
    markers=markers,
    style="species",
)
plt.xlabel(selected_x_var)
plt.ylabel(selected_y_var)
plt.title("Scatterplot of Palmer's Penguins")
st.pyplot(fig)