import gradio as gr import matplotlib.pyplot as plt import seaborn as sns from .utils import plt_to_html def generate_plots_and_tables(quran_data): """ Generate visualization plots and statistics tables for the Quran data. Args: quran_data (pd.DataFrame): The Quran dataset Returns: str: HTML formatted plots and tables """ # Plot 1: Number of verses in each chapter plt.figure(figsize=(30, 10)) sns.set_style('whitegrid') value_counts = quran_data['Surah Name'].value_counts() ax = sns.barplot( x=value_counts.index, y=value_counts.values, hue=value_counts.index, palette='viridis', legend=False ) # Add value labels on bars for container in ax.containers: ax.bar_label(container, size=10, padding=2) # Customize plot ax.set_title('Number of Verses in Each Chapter', fontweight='bold', fontsize=14) ax.set_ylabel('Number of Verses', fontweight='bold') ax.set_xlabel('Surah Name', fontweight='bold') plt.xticks(rotation=90) plt.tight_layout() # Convert plot to HTML plot1_html = plt_to_html(plt) # Generate statistics table surah_counts = quran_data['Surah Name'].value_counts().reset_index() surah_counts.columns = ['Surah Name', 'Ayah Count'] table_html = surah_counts.to_html( index=False, classes='table table-striped table-hover' ) table_html = f'