{"spec_id":"histogram-density","library":"seaborn","language":"python","code":"\"\"\" anyplot.ai\nhistogram-density: Density Histogram\nLibrary: seaborn 0.13.2 | Python 3.13.13\nQuality: 81/100 | Updated: 2026-05-11\n\"\"\"\n\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport seaborn as sns\n\n\n# Data - Generate realistic test scores with bimodal distribution\nnp.random.seed(42)\n# Create bimodal distribution (two groups of students with different means)\ngroup1 = np.random.normal(loc=65, scale=10, size=300)  # Average performers\ngroup2 = np.random.normal(loc=85, scale=5, size=200)  # High performers\ntest_scores = np.concatenate([group1, group2])\n# Clip to realistic test score range\ntest_scores = np.clip(test_scores, 0, 100)\n\n# Create figure\nfig, ax = plt.subplots(figsize=(16, 9))\n\n# Plot density histogram\nsns.histplot(\n    test_scores,\n    stat=\"density\",\n    bins=25,\n    color=\"#306998\",\n    alpha=0.7,\n    edgecolor=\"white\",\n    linewidth=1.5,\n    ax=ax,\n    kde=False,\n    label=\"Density Histogram\",\n)\n\n# Add KDE overlay for smooth density estimate (seaborn feature)\nsns.kdeplot(test_scores, ax=ax, color=\"#FFD43B\", linewidth=4, label=\"Kernel Density Estimate (KDE)\")\n\n# Style and labels\nax.set_xlabel(\"Test Score (points)\", fontsize=20)\nax.set_ylabel(\"Probability Density\", fontsize=20)\nax.set_title(\"histogram-density · seaborn · pyplots.ai\", fontsize=24)\nax.tick_params(axis=\"both\", labelsize=16)\nax.grid(True, alpha=0.3, linestyle=\"--\")\n\n# Legend\nax.legend(fontsize=14, loc=\"upper left\")\n\nplt.tight_layout()\nplt.savefig(\"plot.png\", dpi=300, bbox_inches=\"tight\")\n"}