Update app.py
Browse files
app.py
CHANGED
|
@@ -374,24 +374,6 @@ def compute_student_metrics(df):
|
|
| 374 |
student_metrics_df.rename(columns={'index': 'Student'}, inplace=True)
|
| 375 |
return student_metrics_df
|
| 376 |
|
| 377 |
-
def plot_student_metrics(student_metrics_df):
|
| 378 |
-
# Create a line graph for attendance and engagement
|
| 379 |
-
fig, ax = plt.subplots()
|
| 380 |
-
|
| 381 |
-
# Plotting Attendance and Engagement with specific colors
|
| 382 |
-
ax.plot(student_metrics_df['Student'], student_metrics_df['Attendance (%)'], marker='o', color='#005288', label='Attendance (%)')
|
| 383 |
-
ax.plot(student_metrics_df['Student'], student_metrics_df['Engagement (%)'], marker='o', color='#3AB0FF', label='Engagement (%)')
|
| 384 |
-
|
| 385 |
-
ax.set_xlabel('Student')
|
| 386 |
-
ax.set_ylabel('Percentage (%)')
|
| 387 |
-
ax.set_title('Student Attendance and Engagement Metrics')
|
| 388 |
-
ax.legend()
|
| 389 |
-
plt.xticks(rotation=45)
|
| 390 |
-
|
| 391 |
-
st.pyplot(fig)
|
| 392 |
-
|
| 393 |
-
return fig
|
| 394 |
-
|
| 395 |
def plot_student_metrics(student_metrics_df):
|
| 396 |
# Create the figure and axis
|
| 397 |
fig, ax = plt.subplots(figsize=(10, 6)) # Increased figure size for better readability
|
|
@@ -425,9 +407,10 @@ def plot_student_metrics(student_metrics_df):
|
|
| 425 |
ax.set_xlabel('Student')
|
| 426 |
ax.set_ylabel('Percentage (%)')
|
| 427 |
ax.set_title('Student Attendance and Engagement Metrics')
|
| 428 |
-
ax.legend()
|
|
|
|
| 429 |
ax.set_xticks(index) # Set x-ticks to the index
|
| 430 |
-
ax.set_xticklabels(student_metrics_df['Student'], rotation=
|
| 431 |
|
| 432 |
# Display the plot
|
| 433 |
plt.tight_layout() # Adjust layout to fit elements
|
|
|
|
| 374 |
student_metrics_df.rename(columns={'index': 'Student'}, inplace=True)
|
| 375 |
return student_metrics_df
|
| 376 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 377 |
def plot_student_metrics(student_metrics_df):
|
| 378 |
# Create the figure and axis
|
| 379 |
fig, ax = plt.subplots(figsize=(10, 6)) # Increased figure size for better readability
|
|
|
|
| 407 |
ax.set_xlabel('Student')
|
| 408 |
ax.set_ylabel('Percentage (%)')
|
| 409 |
ax.set_title('Student Attendance and Engagement Metrics')
|
| 410 |
+
# ax.legend()
|
| 411 |
+
ax.legend(loc='upper right', bbox_to_anchor=(1, 1), title="Metrics")
|
| 412 |
ax.set_xticks(index) # Set x-ticks to the index
|
| 413 |
+
ax.set_xticklabels(student_metrics_df['Student'], rotation=0, ha='right') # Set student names as x-tick labels
|
| 414 |
|
| 415 |
# Display the plot
|
| 416 |
plt.tight_layout() # Adjust layout to fit elements
|