{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "imports",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "from pyprojroot import here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "load",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = pd.read_csv(here() / 'data/base/data.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "plot",
   "metadata": {},
   "outputs": [],
   "source": [
    "fig, axes = plt.subplots(2, 2, figsize=(14, 10))\n",
    "\n",
    "# Group by detector type\n",
    "detector_groups = data.groupby('Detector Type')\n",
    "\n",
    "# Bell parameter by detector\n",
    "ax1 = axes[0, 0]\n",
    "detector_bell = detector_groups['Bell Parameter (S)'].mean().sort_values(ascending=False)\n",
    "ax1.bar(range(len(detector_bell)), detector_bell.values, color='steelblue', edgecolor='black')\n",
    "ax1.set_xticks(range(len(detector_bell)))\n",
    "ax1.set_xticklabels(detector_bell.index, rotation=45)\n",
    "ax1.set_ylabel('Mean Bell Parameter (S)', fontsize=11)\n",
    "ax1.set_title('Bell Parameter by Detector Type', fontsize=12)\n",
    "ax1.grid(True, alpha=0.3, axis='y')\n",
    "\n",
    "# Fidelity by detector\n",
    "ax2 = axes[0, 1]\n",
    "detector_fid = detector_groups['Entanglement Fidelity'].mean().sort_values(ascending=False)\n",
    "ax2.bar(range(len(detector_fid)), detector_fid.values, color='coral', edgecolor='black')\n",
    "ax2.set_xticks(range(len(detector_fid)))\n",
    "ax2.set_xticklabels(detector_fid.index, rotation=45)\n",
    "ax2.set_ylabel('Mean Entanglement Fidelity', fontsize=11)\n",
    "ax2.set_title('Fidelity by Detector Type', fontsize=12)\n",
    "ax2.grid(True, alpha=0.3, axis='y')\n",
    "\n",
    "# Detection efficiency by detector\n",
    "ax3 = axes[1, 0]\n",
    "detector_eff = detector_groups['Detection Efficiency A (%)'].mean().sort_values(ascending=False)\n",
    "ax3.bar(range(len(detector_eff)), detector_eff.values, color='mediumseagreen', edgecolor='black')\n",
    "ax3.set_xticks(range(len(detector_eff)))\n",
    "ax3.set_xticklabels(detector_eff.index, rotation=45)\n",
    "ax3.set_ylabel('Mean Detection Efficiency (%)', fontsize=11)\n",
    "ax3.set_title('Detection Efficiency by Detector Type', fontsize=12)\n",
    "ax3.grid(True, alpha=0.3, axis='y')\n",
    "\n",
    "# Sample counts\n",
    "ax4 = axes[1, 1]\n",
    "detector_counts = data['Detector Type'].value_counts()\n",
    "ax4.bar(range(len(detector_counts)), detector_counts.values, color='mediumpurple', edgecolor='black')\n",
    "ax4.set_xticks(range(len(detector_counts)))\n",
    "ax4.set_xticklabels(detector_counts.index, rotation=45)\n",
    "ax4.set_ylabel('Number of Experiments', fontsize=11)\n",
    "ax4.set_title('Sample Size by Detector Type', fontsize=12)\n",
    "ax4.grid(True, alpha=0.3, axis='y')\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.savefig(here() / 'output/plots/detector_comparison.png', dpi=300, bbox_inches='tight')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
