Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -373,22 +373,26 @@ elif menu == "Graph":
|
|
| 373 |
selected_users = [user for user, visible in user_data.items() if visible]
|
| 374 |
filtered_item_counts = item_counts[item_counts['Item'].isin(selected_items) & item_counts['User'].isin(selected_users)]
|
| 375 |
|
| 376 |
-
#
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 393 |
else:
|
| 394 |
st.write("No historical data available to plot.")
|
|
|
|
| 373 |
selected_users = [user for user, visible in user_data.items() if visible]
|
| 374 |
filtered_item_counts = item_counts[item_counts['Item'].isin(selected_items) & item_counts['User'].isin(selected_users)]
|
| 375 |
|
| 376 |
+
# Check if there is data to display
|
| 377 |
+
if not filtered_item_counts.empty:
|
| 378 |
+
# Create a line plot for each selected item over time
|
| 379 |
+
plt.figure(figsize=(12, 6))
|
| 380 |
+
sns.lineplot(data=filtered_item_counts, x='Date', y='Count', hue='Item', marker='o')
|
| 381 |
+
|
| 382 |
+
# Customize the y-axis to show only integer labels
|
| 383 |
+
y_max = max(filtered_item_counts['Count'].max() + 1, 1) # Set y_max to at least 1 to avoid errors
|
| 384 |
+
plt.yticks(range(0, y_max)) # Show only integer labels on the y-axis
|
| 385 |
+
|
| 386 |
+
# Customize the plot
|
| 387 |
+
plt.xticks(rotation=45)
|
| 388 |
+
plt.title('Item Selections Over Time')
|
| 389 |
+
plt.xlabel('Date')
|
| 390 |
+
plt.ylabel('Number of Selections')
|
| 391 |
+
plt.legend(loc='upper center', bbox_to_anchor=(0.5, -0.15), ncol=3)
|
| 392 |
+
|
| 393 |
+
# Display the plot
|
| 394 |
+
st.pyplot(plt.gcf())
|
| 395 |
+
else:
|
| 396 |
+
st.write("No data to display. Please select at least one user and one item.")
|
| 397 |
else:
|
| 398 |
st.write("No historical data available to plot.")
|