ProfessorLeVesseur commited on
Commit
1329e4d
·
verified ·
1 Parent(s): f1740fa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -429,32 +429,32 @@ def compute_student_metrics(df):
429
  # # Display the plot
430
  # st.pyplot(fig)
431
 
432
- def plot_student_metrics(student_metrics_df):
433
  # Create the figure and axis
434
  fig, ax = plt.subplots(figsize=(10, 6)) # Increased figure size for better readability
435
-
436
  # Width for the bars and offset for overlapping effect
437
  bar_width = 0.4
438
  index = range(len(student_metrics_df))
439
-
440
  # Plot Attendance and Engagement bars side by side with transparency
441
  attendance_bars = ax.bar([i - bar_width/2 for i in index], student_metrics_df['Attendance (%)'],
442
  width=bar_width, label='Attendance (%)', color='#005288', alpha=0.7)
443
  engagement_bars = ax.bar([i + bar_width/2 for i in index], student_metrics_df['Engagement (%)'],
444
  width=bar_width, label='Engagement (%)', color='#3AB0FF', alpha=0.7)
445
-
446
  # Add labels to each bar with customized font size and color
447
  font_size = 8 # Reduced font size for better fit
448
  for bar in attendance_bars:
449
  height = bar.get_height()
450
  ax.text(bar.get_x() + bar.get_width() / 2, height, f'{height:.1f}%',
451
  ha='center', va='bottom', color='white', fontsize=font_size)
452
-
453
  for bar in engagement_bars:
454
  height = bar.get_height()
455
  ax.text(bar.get_x() + bar.get_width() / 2, height, f'{height:.1f}%',
456
  ha='center', va='bottom', color='black', fontsize=font_size)
457
-
458
  # Set labels, title, and legend
459
  ax.set_xlabel('Student')
460
  ax.set_ylabel('Percentage (%)')
@@ -462,13 +462,13 @@ def compute_student_metrics(df):
462
  ax.legend()
463
  ax.set_xticks(index)
464
  ax.set_xticklabels(student_metrics_df['Student'], rotation=45, ha='right') # Improved xticklabel alignment
465
-
466
  # Tight layout to ensure all elements fit within the figure
467
  fig.tight_layout()
468
-
469
  # Display the plot
470
  st.pyplot(fig)
471
-
472
  return fig
473
  return fig
474
 
 
429
  # # Display the plot
430
  # st.pyplot(fig)
431
 
432
+ def plot_student_metrics(student_metrics_df):
433
  # Create the figure and axis
434
  fig, ax = plt.subplots(figsize=(10, 6)) # Increased figure size for better readability
435
+
436
  # Width for the bars and offset for overlapping effect
437
  bar_width = 0.4
438
  index = range(len(student_metrics_df))
439
+
440
  # Plot Attendance and Engagement bars side by side with transparency
441
  attendance_bars = ax.bar([i - bar_width/2 for i in index], student_metrics_df['Attendance (%)'],
442
  width=bar_width, label='Attendance (%)', color='#005288', alpha=0.7)
443
  engagement_bars = ax.bar([i + bar_width/2 for i in index], student_metrics_df['Engagement (%)'],
444
  width=bar_width, label='Engagement (%)', color='#3AB0FF', alpha=0.7)
445
+
446
  # Add labels to each bar with customized font size and color
447
  font_size = 8 # Reduced font size for better fit
448
  for bar in attendance_bars:
449
  height = bar.get_height()
450
  ax.text(bar.get_x() + bar.get_width() / 2, height, f'{height:.1f}%',
451
  ha='center', va='bottom', color='white', fontsize=font_size)
452
+
453
  for bar in engagement_bars:
454
  height = bar.get_height()
455
  ax.text(bar.get_x() + bar.get_width() / 2, height, f'{height:.1f}%',
456
  ha='center', va='bottom', color='black', fontsize=font_size)
457
+
458
  # Set labels, title, and legend
459
  ax.set_xlabel('Student')
460
  ax.set_ylabel('Percentage (%)')
 
462
  ax.legend()
463
  ax.set_xticks(index)
464
  ax.set_xticklabels(student_metrics_df['Student'], rotation=45, ha='right') # Improved xticklabel alignment
465
+
466
  # Tight layout to ensure all elements fit within the figure
467
  fig.tight_layout()
468
+
469
  # Display the plot
470
  st.pyplot(fig)
471
+
472
  return fig
473
  return fig
474