hyzhang00 commited on
Commit
7ded404
·
verified ·
1 Parent(s): b508eb9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -48
app.py CHANGED
@@ -69,27 +69,19 @@ temporal_viz = (
69
 
70
  st.altair_chart(temporal_viz)
71
 
72
- st.markdown("""
73
- **(1) Features Highlighted**
74
 
75
- This visualization emphasizes the temporal evolution of UFO sightings, with enhanced interactive features:
76
- - Adjustable time range using the slider
77
- - Choice between yearly and monthly aggregation
78
- - Interactive area and line combination chart
79
- - Hover tooltips for detailed information
80
 
81
  **(2) Design Choices**
82
 
83
  I implemented several key design elements for optimal data representation:
84
- + Combined area and line chart to show both trends and volume
85
- + Interactive time range selection for focused analysis
86
- + Multiple temporal granularity options
87
- + Synchronized area, line, and point markers for clear data representation
88
 
89
  **(3) Potential Improvements**
90
 
91
- Future enhancements could include seasonal analysis and correlation with historical events.
92
- """)
93
 
94
  st.markdown("## 2. Analysis of UFO Shape Distribution")
95
 
@@ -100,32 +92,16 @@ selected_shapes = st.multiselect(
100
  default=all_shapes[:10]
101
  )
102
 
103
- sort_option = st.selectbox(
104
- "Sort By",
105
- ['Frequency', 'Alphabetical', 'Average Duration']
106
- )
107
-
108
  filtered_df = df[df['shape'].isin(selected_shapes)]
109
-
110
- if sort_option == 'Frequency':
111
- shape_counts = filtered_df['shape'].value_counts().reset_index()
112
- shape_counts.columns = ['shape', 'count']
113
- sort_field = '-x'
114
- elif sort_option == 'Alphabetical':
115
- shape_counts = filtered_df['shape'].value_counts().reset_index()
116
- shape_counts.columns = ['shape', 'count']
117
- sort_field = 'shape'
118
- else:
119
- shape_counts = filtered_df.groupby('shape')['duration_seconds'].mean().reset_index()
120
- shape_counts.columns = ['shape', 'count']
121
- sort_field = '-count'
122
 
123
  shape_viz = alt.Chart(shape_counts).mark_bar().encode(
124
  y=alt.Y('shape:N',
125
- sort=sort_field,
126
  title='UFO Shape'),
127
  x=alt.X('count:Q',
128
- title='Number of Reports' if sort_option == 'Frequency' else 'Average Duration (seconds)'),
129
  color=alt.Color('count:Q', scale=alt.Scale(scheme='viridis')),
130
  tooltip=['shape:N', 'count:Q']
131
  ).properties(
@@ -135,25 +111,18 @@ shape_viz = alt.Chart(shape_counts).mark_bar().encode(
135
 
136
  st.altair_chart(shape_viz)
137
 
138
- st.markdown("""
139
- **(1) Features Highlighted**
140
 
141
- This enhanced visualization now includes:
142
- - Multiple shape selection capability
143
- - Dynamic sorting options
144
- - Color encoding for better pattern recognition
145
- - Interactive tooltips and filtering
146
 
147
  **(2) Design Choices**
148
 
149
- The visualization employs several interactive elements:
150
- + Multi-select dropdown for shape filtering
151
- + Dynamic sorting options for different analytical perspectives
152
- + Color gradient to emphasize differences
153
- + Responsive height adjustment based on selected shapes
154
- + Interactive tooltips for detailed information
155
 
156
  **(3) Potential Improvements**
157
 
158
- Future enhancements could include geographical distribution analysis and temporal trend analysis by shape.
159
- """)
 
69
 
70
  st.altair_chart(temporal_viz)
71
 
72
+ st.markdown("""**(1) Features Highlighted**
 
73
 
74
+ This visualization emphasizes the temporal evolution of UFO sightings from 1949 to 2013, highlighting both the overall trend and year-specific fluctuations in reporting frequency. The visualization reveals distinct patterns of increased reporting over time, with notable spikes in certain periods that could correlate with significant historical events or changes in reporting methods.
 
 
 
 
75
 
76
  **(2) Design Choices**
77
 
78
  I implemented several key design elements for optimal data representation:
79
+ + A line chart with point markers was chosen for its effectiveness in showing continuous time-series data while maintaining precise year-specific values
80
+ + Interactive tooltips were added to provide exact sighting counts
 
 
81
 
82
  **(3) Potential Improvements**
83
 
84
+ Given more time, I would implement dual y-axes to show both sighting frequency and duration, and add the capability to filter by time periods and incorporate monthly/seasonal analysis options.""")
 
85
 
86
  st.markdown("## 2. Analysis of UFO Shape Distribution")
87
 
 
92
  default=all_shapes[:10]
93
  )
94
 
 
 
 
 
 
95
  filtered_df = df[df['shape'].isin(selected_shapes)]
96
+ shape_counts = filtered_df['shape'].value_counts().reset_index()
97
+ shape_counts.columns = ['shape', 'count']
 
 
 
 
 
 
 
 
 
 
 
98
 
99
  shape_viz = alt.Chart(shape_counts).mark_bar().encode(
100
  y=alt.Y('shape:N',
101
+ sort='-x',
102
  title='UFO Shape'),
103
  x=alt.X('count:Q',
104
+ title='Number of Reports'),
105
  color=alt.Color('count:Q', scale=alt.Scale(scheme='viridis')),
106
  tooltip=['shape:N', 'count:Q']
107
  ).properties(
 
111
 
112
  st.altair_chart(shape_viz)
113
 
114
+ st.markdown("""**(1) Features Highlighted**
 
115
 
116
+ This visualization focuses on the distribution of reported UFO shapes. The data shows clear preferences in how witnesses describe UFO shapes, with certain forms being consistently more common across reports. This analysis helps identify patterns in how people perceive and describe unidentified flying objects.
 
 
 
 
117
 
118
  **(2) Design Choices**
119
 
120
+ The visualization employs several intentional design elements:
121
+ + A horizontal bar chart format was chosen to accommodate long shape labels and enable easy comparison of quantities
122
+ + Bars are sorted in descending order to immediately highlight the most common shapes
123
+ + The chart focuses on the top 10 shapes to maintain clarity and prevent information overload
124
+ + Interactive tooltips provide precise counts for each shape category.
 
125
 
126
  **(3) Potential Improvements**
127
 
128
+ With additional time, I would expand this visualization by adding temporal analysis to show how shape distributions have changed over decades, incorporate geographical analysis to reveal regional patterns in shape reporting.""")