Spaces:
Sleeping
Sleeping
anishak05
commited on
Commit
·
04603f4
1
Parent(s):
7141fdc
Add:Files and app.py changes
Browse files- .gitignore +1 -0
- app.py +51 -58
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.venv
|
app.py
CHANGED
@@ -1,73 +1,66 @@
|
|
1 |
-
|
2 |
-
# 1. Open a "Terminal" by: View --> Terminal OR just the "Terminal" through the hamburger menu
|
3 |
-
# 2. run in terminal with: streamlit run app.py
|
4 |
-
# 3. click the "Open in Browser" link that pops up OR click on "Ports" and copy the URL
|
5 |
-
# 4. Open a Simple Browswer with View --> Command Palette --> Simple Browser: Show
|
6 |
-
# 5. use the URL from prior steps as intput into this simple browser
|
7 |
-
|
8 |
-
|
9 |
import streamlit as st
|
10 |
import altair as alt
|
11 |
-
|
12 |
-
|
13 |
st.title("Streamlit App for IS445: ID29937")
|
14 |
|
|
|
15 |
st.text("The URL for this app is: https://huggingface.co/spaces/Shrek29/is445_demo")
|
16 |
|
17 |
-
|
|
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
range=["#e7ba52", "#a7a7a7", "#aec7e8", "#1f77b4", "#9467bd"],
|
22 |
-
)
|
23 |
-
color = alt.Color("weather:N", scale=scale)
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
# - a multi-click that is active on the bottom panel
|
28 |
-
brush = alt.selection_interval(encodings=["x"])
|
29 |
-
click = alt.selection_point(encodings=["color"])
|
30 |
|
31 |
-
#
|
32 |
-
|
33 |
-
alt.Chart()
|
34 |
-
|
35 |
-
|
36 |
-
alt.
|
37 |
-
alt.
|
38 |
-
|
39 |
-
|
40 |
-
scale=alt.Scale(domain=[-5, 40]),
|
41 |
-
),
|
42 |
-
color=alt.condition(brush, color, alt.value("lightgray")),
|
43 |
-
size=alt.Size("precipitation:Q", scale=alt.Scale(range=[5, 200])),
|
44 |
-
)
|
45 |
-
.properties(width=550, height=300)
|
46 |
-
.add_params(brush)
|
47 |
-
.transform_filter(click)
|
48 |
)
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
.
|
61 |
-
|
62 |
-
)
|
63 |
-
.add_params(click)
|
64 |
)
|
65 |
|
66 |
-
|
|
|
|
|
|
|
67 |
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
with tab2:
|
73 |
-
st.altair_chart(chart, theme=None, use_container_width=True)
|
|
|
1 |
+
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import streamlit as st
|
3 |
import altair as alt
|
4 |
+
|
5 |
+
# Main title for the app
|
6 |
st.title("Streamlit App for IS445: ID29937")
|
7 |
|
8 |
+
# Text description with URL
|
9 |
st.text("The URL for this app is: https://huggingface.co/spaces/Shrek29/is445_demo")
|
10 |
|
11 |
+
# Divider to separate sections
|
12 |
+
st.divider()
|
13 |
|
14 |
+
# Header for the scatter plot section
|
15 |
+
st.header("Scatter Plot of Weather Data from the BFRO Dataset")
|
|
|
|
|
|
|
16 |
|
17 |
+
source = "https://raw.githubusercontent.com/UIUC-iSchool-DataViz/is445_data/main/bfro_reports_fall2022.csv"
|
18 |
+
data = pd.read_csv(source).dropna()
|
|
|
|
|
|
|
19 |
|
20 |
+
# Scatter plot using Altair
|
21 |
+
scatter = (
|
22 |
+
alt.Chart(data).mark_circle().encode(
|
23 |
+
alt.X('visibility:Q').title('Visibility'),
|
24 |
+
alt.Y('wind_speed:Q').title('Wind Speed'),
|
25 |
+
alt.Color('season:N').scale(scheme="set2"), # Using 'set2' color scheme
|
26 |
+
alt.Size('temperature_high:Q'),
|
27 |
+
alt.Tooltip(['visibility', 'wind_speed', 'season', 'pressure'])
|
28 |
+
).interactive()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
)
|
30 |
|
31 |
+
st.altair_chart(scatter, use_container_width=True)
|
32 |
+
|
33 |
+
# Divider to separate sections
|
34 |
+
st.divider()
|
35 |
+
|
36 |
+
# Header for mixed chart section
|
37 |
+
st.header("Mixed Chart of Weather Data from the BFRO Dataset")
|
38 |
+
|
39 |
+
pts = alt.selection_point(encodings=['x'])
|
40 |
+
rect = alt.Chart(data).mark_rect().encode(
|
41 |
+
alt.X('uv_index:Q').bin().title('UV Index'),
|
42 |
+
alt.Y('cloud_cover:Q').bin().title('Cloud Cover'),
|
43 |
+
alt.Color('count()').scale(scheme='greens').title('Count of UV Index'),
|
|
|
44 |
)
|
45 |
|
46 |
+
circ = rect.mark_point().encode(
|
47 |
+
alt.ColorValue('darkred'), # Change point color to dark red
|
48 |
+
alt.Size('count()').title('Count of Cloud Cover')
|
49 |
+
).transform_filter(pts)
|
50 |
|
51 |
+
bar = alt.Chart(data, width=550, height=200).mark_bar().encode(
|
52 |
+
x='season:N',
|
53 |
+
y='count()',
|
54 |
+
color=alt.condition(pts, alt.ColorValue("orange"), alt.ColorValue("grey"))
|
55 |
+
).add_params(pts)
|
56 |
+
|
57 |
+
special = alt.vconcat(
|
58 |
+
rect + circ,
|
59 |
+
bar
|
60 |
+
).resolve_legend(
|
61 |
+
color="independent",
|
62 |
+
size="independent"
|
63 |
+
)
|
64 |
|
65 |
+
# Display mixed chart
|
66 |
+
st.altair_chart(special)
|
|
|
|