Update app.py
Browse files
app.py
CHANGED
|
@@ -164,11 +164,13 @@ def main():
|
|
| 164 |
intervention_stats = compute_intervention_statistics(df)
|
| 165 |
st.subheader("Intervention Session Statistics")
|
| 166 |
st.write(intervention_stats)
|
| 167 |
-
|
| 168 |
# Two-column layout for the visualization and intervention frequency
|
| 169 |
-
col1, col2 = st.columns(2)
|
|
|
|
| 170 |
with col1:
|
| 171 |
intervention_fig = plot_intervention_statistics(intervention_stats)
|
|
|
|
| 172 |
with col2:
|
| 173 |
intervention_frequency = intervention_stats['Intervention Frequency (%)'].values[0]
|
| 174 |
st.markdown(f"<h1 style='color: #358E66;'>{intervention_frequency}%</h1>", unsafe_allow_html=True)
|
|
@@ -258,12 +260,14 @@ def plot_intervention_statistics(intervention_stats):
|
|
| 258 |
sessions_not_held = intervention_stats['Intervention Sessions Not Held'].values[0]
|
| 259 |
|
| 260 |
fig, ax = plt.subplots()
|
| 261 |
-
|
| 262 |
-
ax.bar(['Intervention Sessions'], [
|
|
|
|
|
|
|
| 263 |
|
| 264 |
# Display values on the bars
|
| 265 |
-
ax.text(0,
|
| 266 |
-
ax.text(0,
|
| 267 |
|
| 268 |
# Update chart settings
|
| 269 |
ax.set_ylabel('Frequency')
|
|
|
|
| 164 |
intervention_stats = compute_intervention_statistics(df)
|
| 165 |
st.subheader("Intervention Session Statistics")
|
| 166 |
st.write(intervention_stats)
|
| 167 |
+
|
| 168 |
# Two-column layout for the visualization and intervention frequency
|
| 169 |
+
col1, col2 = st.columns([2, 1]) # Set the column width ratio
|
| 170 |
+
|
| 171 |
with col1:
|
| 172 |
intervention_fig = plot_intervention_statistics(intervention_stats)
|
| 173 |
+
|
| 174 |
with col2:
|
| 175 |
intervention_frequency = intervention_stats['Intervention Frequency (%)'].values[0]
|
| 176 |
st.markdown(f"<h1 style='color: #358E66;'>{intervention_frequency}%</h1>", unsafe_allow_html=True)
|
|
|
|
| 260 |
sessions_not_held = intervention_stats['Intervention Sessions Not Held'].values[0]
|
| 261 |
|
| 262 |
fig, ax = plt.subplots()
|
| 263 |
+
# Plot "Held" on the bottom
|
| 264 |
+
ax.bar(['Intervention Sessions'], [sessions_held], label='Held', color='#358E66')
|
| 265 |
+
# Plot "Not Held" on top of "Held"
|
| 266 |
+
ax.bar(['Intervention Sessions'], [sessions_not_held], bottom=[sessions_held], label='Not Held', color='#91D6B8')
|
| 267 |
|
| 268 |
# Display values on the bars
|
| 269 |
+
ax.text(0, sessions_held / 2, str(sessions_held), ha='center', va='center', color='white')
|
| 270 |
+
ax.text(0, sessions_held + sessions_not_held / 2, str(sessions_not_held), ha='center', va='center', color='black')
|
| 271 |
|
| 272 |
# Update chart settings
|
| 273 |
ax.set_ylabel('Frequency')
|