Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -60,31 +60,30 @@ if viz_button:
|
|
| 60 |
st.subheader("Expense Summary")
|
| 61 |
category_summary = st.session_state['expenses'].groupby('Category')['Amount'].sum().reset_index()
|
| 62 |
|
| 63 |
-
fig, ax = plt.subplots()
|
| 64 |
sns.barplot(y='Category', x='Amount', data=category_summary, ax=ax) # Horizontal bar plot
|
| 65 |
-
ax.set_title("Total Expenses by Category") # Title for the bar plot
|
| 66 |
-
ax.set_xlabel("
|
| 67 |
-
ax.set_ylabel("Category") # Y-axis label
|
| 68 |
|
| 69 |
# Adding labels to each bar
|
| 70 |
for index, value in enumerate(category_summary['Amount']):
|
| 71 |
-
ax.text(value, index, f'{value:.2f}', va='center')
|
| 72 |
|
| 73 |
st.pyplot(fig)
|
| 74 |
|
| 75 |
# Expenses Over Time Line Chart with Title, Labels, and Point Labels
|
| 76 |
st.subheader("Expenses Over Time")
|
| 77 |
-
fig, ax = plt.subplots()
|
| 78 |
expenses_over_time = st.session_state['expenses'].set_index('Date')['Amount']
|
| 79 |
ax.plot(expenses_over_time, marker='o')
|
| 80 |
-
ax.set_title("Expenses Over Time") # Title for the line chart
|
| 81 |
-
ax.
|
| 82 |
-
ax.set_ylabel("Amount Spent") # Y-axis label
|
| 83 |
|
| 84 |
# Adding labels to each point
|
| 85 |
for date, amount in expenses_over_time.items():
|
| 86 |
-
ax.text(date, amount, f'{amount:.2f}', ha='right')
|
| 87 |
-
|
|
|
|
| 88 |
st.pyplot(fig)
|
| 89 |
|
| 90 |
|
|
|
|
| 60 |
st.subheader("Expense Summary")
|
| 61 |
category_summary = st.session_state['expenses'].groupby('Category')['Amount'].sum().reset_index()
|
| 62 |
|
| 63 |
+
fig, ax = plt.subplots(figsize=(10,6))
|
| 64 |
sns.barplot(y='Category', x='Amount', data=category_summary, ax=ax) # Horizontal bar plot
|
| 65 |
+
ax.set_title("Total Expenses by Category", pad=20) # Title for the bar plot
|
| 66 |
+
ax.set_xlabel("Amount Spent (£)", labelpad=15) # X-axis label
|
|
|
|
| 67 |
|
| 68 |
# Adding labels to each bar
|
| 69 |
for index, value in enumerate(category_summary['Amount']):
|
| 70 |
+
ax.text(value + 0.05, index, f'{value:.2f}', va='center')
|
| 71 |
|
| 72 |
st.pyplot(fig)
|
| 73 |
|
| 74 |
# Expenses Over Time Line Chart with Title, Labels, and Point Labels
|
| 75 |
st.subheader("Expenses Over Time")
|
| 76 |
+
fig, ax = plt.subplots(figsize=(10,6))
|
| 77 |
expenses_over_time = st.session_state['expenses'].set_index('Date')['Amount']
|
| 78 |
ax.plot(expenses_over_time, marker='o')
|
| 79 |
+
ax.set_title("Expenses Over Time", pad=20) # Title for the line chart
|
| 80 |
+
ax.set_ylabel("Amount Spent (£)", labelpad=5) # Y-axis label
|
|
|
|
| 81 |
|
| 82 |
# Adding labels to each point
|
| 83 |
for date, amount in expenses_over_time.items():
|
| 84 |
+
ax.text(date, amount + 0.05, f'{amount:.2f}', ha='right')
|
| 85 |
+
|
| 86 |
+
plt.xticks(rotation=45)
|
| 87 |
st.pyplot(fig)
|
| 88 |
|
| 89 |
|