{"spec_id":"rose-basic","library":"seaborn","language":"python","code":"\"\"\" anyplot.ai\nrose-basic: Basic Rose Chart\nLibrary: seaborn 0.13.2 | Python 3.13.14\nQuality: 87/100 | Updated: 2026-07-25\n\"\"\"\n\nimport os\n\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport seaborn as sns\n\n\n# Theme tokens\nTHEME = os.getenv(\"ANYPLOT_THEME\", \"light\")\nPAGE_BG = \"#FAF8F1\" if THEME == \"light\" else \"#1A1A17\"\nELEVATED_BG = \"#FFFDF6\" if THEME == \"light\" else \"#242420\"\nINK = \"#1A1A17\" if THEME == \"light\" else \"#F0EFE8\"\nINK_SOFT = \"#4A4A44\" if THEME == \"light\" else \"#B8B7B0\"\n\n# Apply seaborn theme with full adaptive chrome\nsns.set_theme(\n    style=\"ticks\",\n    rc={\n        \"figure.facecolor\": PAGE_BG,\n        \"axes.facecolor\": PAGE_BG,\n        \"axes.edgecolor\": INK_SOFT,\n        \"axes.labelcolor\": INK,\n        \"text.color\": INK,\n        \"xtick.color\": INK_SOFT,\n        \"ytick.color\": INK_SOFT,\n        \"grid.color\": INK,\n        \"grid.alpha\": 0.15,\n        \"legend.facecolor\": ELEVATED_BG,\n        \"legend.edgecolor\": INK_SOFT,\n    },\n)\n\n# Data: Monthly rainfall (mm) showing seasonal patterns\nmonths = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\nrainfall = [89, 72, 95, 112, 135, 168, 142, 125, 98, 76, 82, 91]\n\n# Calculate angles - start at top (12 o'clock position)\nn_categories = len(months)\nangles = np.linspace(0, 2 * np.pi, n_categories, endpoint=False)\nwidth = 2 * np.pi / n_categories * 0.85\n\n# Create figure with polar projection — canonical square canvas (2400x2400 @ dpi=400)\nfig, ax = plt.subplots(figsize=(6, 6), dpi=400, subplot_kw={\"projection\": \"polar\"})\nfig.patch.set_facecolor(PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\n# Imprint sequential ramp (brand green -> blue) built via seaborn's blend_palette,\n# assigned by rainfall rank so color depth reflects magnitude regardless of month order\nvalue_ranks = np.argsort(np.argsort(rainfall))\nimprint_seq = sns.blend_palette([\"#009E73\", \"#4467A3\"], n_colors=n_categories)\nbar_colors = [imprint_seq[rank] for rank in value_ranks]\n\n# Plot bars - radius proportional to value\nax.bar(angles, rainfall, width=width, bottom=0, color=bar_colors, edgecolor=INK_SOFT, linewidth=1, alpha=0.92, zorder=2)\n\n# Configure polar axis - start at top (12 o'clock), clockwise\nax.set_theta_offset(np.pi / 2)\nax.set_theta_direction(-1)\n\n# Category labels\nax.set_xticks(angles)\nax.set_xticklabels(months, fontsize=11, fontweight=\"bold\", color=INK)\nax.tick_params(axis=\"x\", pad=10)\n\n# Radial gridlines and labels. Every month exceeds the innermost gridline, so the \"50 mm\"\n# tick always lands inside a bar. seaborn's \"axisbelow\" theme forces native tick-label\n# z-order below patches at draw time (any per-label zorder override is silently reset), so\n# that one label is drawn manually as a standalone Text with a halo box instead.\nmax_val = max(rainfall)\nax.set_ylim(0, max_val * 1.15)\nax.set_yticks([50, 100, 150])\nax.set_yticklabels([\"\", \"100 mm\", \"150 mm\"], fontsize=9, color=INK_SOFT)\n# Placed in the angular gap between the Jun/Jul bars (bottom of the chart, away from\n# the title and the Dec/Jan boundary) so the halo box no longer sits on top of bar fill.\ngap_angle = angles[5] + (2 * np.pi / n_categories) / 2\nax.text(\n    gap_angle,\n    50,\n    \"50 mm\",\n    ha=\"center\",\n    va=\"center\",\n    fontsize=9,\n    color=INK_SOFT,\n    zorder=5,\n    bbox={\"facecolor\": PAGE_BG, \"edgecolor\": \"none\", \"alpha\": 0.85, \"pad\": 1.5},\n)\n\n# Grid and spine styling\nax.grid(True, alpha=0.18, linestyle=\"--\", linewidth=1.2, color=INK_SOFT)\nax.spines[\"polar\"].set_visible(False)\n\n# Title (extra pad keeps it clear of the 12 o'clock \"Jan\" tick label)\nax.set_title(\n    \"Monthly Rainfall (mm) · rose-basic · python · seaborn · anyplot.ai\",\n    fontsize=11,\n    fontweight=\"bold\",\n    pad=30,\n    color=INK,\n)\n\n# Value labels on each bar\nfor angle, value in zip(angles, rainfall, strict=True):\n    ax.text(angle, value + 12, f\"{value}\", ha=\"center\", va=\"center\", fontsize=8, fontweight=\"bold\", color=INK_SOFT)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=400, facecolor=PAGE_BG)\n"}