Update app.py
Browse files
app.py
CHANGED
@@ -472,19 +472,6 @@ def plot_student_metrics(student_metrics_df, attendance_avg_stats, engagement_av
|
|
472 |
ax.text(bar.get_x() + bar.get_width() / 2, height,
|
473 |
f'{height:.0f}%', ha='center', va='bottom', color='black') # No decimal for integer percentage
|
474 |
|
475 |
-
# Set labels, title, and legend
|
476 |
-
ax.set_xlabel('Student')
|
477 |
-
ax.set_ylabel('Percentage (%)')
|
478 |
-
ax.set_title('Student Attendance and Engagement Metrics')
|
479 |
-
# ax.legend()
|
480 |
-
# ax.legend(loc='upper right', bbox_to_anchor=(1.25, 1), borderaxespad=0.)
|
481 |
-
ax.legend(loc='upper right')
|
482 |
-
ax.set_xticks(index) # Set x-ticks to the index
|
483 |
-
ax.set_xticklabels(student_metrics_df['Student'], rotation=0, ha='right') # Set student names as x-tick labels
|
484 |
-
# Set the y-axis limits and tick locations
|
485 |
-
ax.set_ylim(0, 100) # Range from 0 to 100
|
486 |
-
ax.yaxis.set_ticks(range(0, 140, 20)) # Increments of 20
|
487 |
-
|
488 |
# Add average lines for attendance and engagement
|
489 |
ax.axhline(
|
490 |
y=attendance_avg_stats,
|
@@ -500,6 +487,19 @@ def plot_student_metrics(student_metrics_df, attendance_avg_stats, engagement_av
|
|
500 |
linewidth=1.5,
|
501 |
label=f'Engagement Average: {engagement_avg_stats}%'
|
502 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
503 |
|
504 |
# Display the plot
|
505 |
plt.tight_layout() # Adjust layout to fit elements
|
|
|
472 |
ax.text(bar.get_x() + bar.get_width() / 2, height,
|
473 |
f'{height:.0f}%', ha='center', va='bottom', color='black') # No decimal for integer percentage
|
474 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
475 |
# Add average lines for attendance and engagement
|
476 |
ax.axhline(
|
477 |
y=attendance_avg_stats,
|
|
|
487 |
linewidth=1.5,
|
488 |
label=f'Engagement Average: {engagement_avg_stats}%'
|
489 |
)
|
490 |
+
|
491 |
+
# Set labels, title, and legend
|
492 |
+
ax.set_xlabel('Student')
|
493 |
+
ax.set_ylabel('Percentage (%)')
|
494 |
+
ax.set_title('Student Attendance and Engagement Metrics')
|
495 |
+
# ax.legend()
|
496 |
+
# ax.legend(loc='upper right', bbox_to_anchor=(1.25, 1), borderaxespad=0.)
|
497 |
+
ax.legend(loc='upper right')
|
498 |
+
ax.set_xticks(index) # Set x-ticks to the index
|
499 |
+
ax.set_xticklabels(student_metrics_df['Student'], rotation=0, ha='right') # Set student names as x-tick labels
|
500 |
+
# Set the y-axis limits and tick locations
|
501 |
+
ax.set_ylim(0, 100) # Range from 0 to 100
|
502 |
+
ax.yaxis.set_ticks(range(0, 119, 20)) # Increments of 20
|
503 |
|
504 |
# Display the plot
|
505 |
plt.tight_layout() # Adjust layout to fit elements
|