-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhello.py
More file actions
68 lines (55 loc) · 1.55 KB
/
hello.py
File metadata and controls
68 lines (55 loc) · 1.55 KB
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
import pandas as pd
import streamlit as st
import plotly.express as px
data = pd.read_csv('iris_data.csv')
st.set_page_config(
page_title='Iris Dataset',
# layout='wide'
)
st.title('Visualisasi Sederhana dengan Iris')
st.write("")
col1, col2 = st.columns([2,6])
with st.sidebar:
st.markdown("**Pilih Spesies**")
setosa_on = st.checkbox('Iris Setosa')
versicolor_on = st.checkbox('Iris Versicolor')
virginica_on = st.checkbox('Iris Virginica')
toggle_list = []
if setosa_on:
toggle_list.append('Iris-setosa')
if versicolor_on:
toggle_list.append('Iris-versicolor')
if virginica_on:
toggle_list.append('Iris-virginica')
data_filter_species = data.query('Species in @toggle_list')
if toggle_list:
used_data = data_filter_species
else:
used_data = data
# with col2:
st.dataframe(used_data, use_container_width=True)
col3, col4 = st.columns(2)
with col3:
st.markdown("**Distribusi Petal Length**")
fig1 = px.histogram(used_data, x = 'PetalLengthCm', color='Species')
st.plotly_chart(fig1, use_container_width=True)
with col4:
st.markdown("**Distribusi Sepal Length**")
fig1 = px.histogram(used_data, x = 'SepalLengthCm', color='Species')
st.plotly_chart(fig1, use_container_width=True)
st.markdown("**Korelasi Antar Variabel**")
var1 = st.radio(
"Pilih Variabel X",
data.columns.tolist()[:-1],
horizontal = True
)
var2 = st.radio(
"Pilih Variabel Y",
data.columns.tolist()[:-1],
horizontal = True
)
fig5 = px.scatter(
used_data, x = var1, y = var2,
hover_data = [var1, var2],
color = 'Species')
st.plotly_chart(fig5, use_container_width=True)