{"spec_id":"polar-basic","library":"matplotlib","language":"python","code":"\"\"\" anyplot.ai\npolar-basic: Basic Polar Chart\nLibrary: matplotlib 3.10.9 | Python 3.13.13\nQuality: 88/100 | Updated: 2026-04-30\n\"\"\"\n\nimport os\n\nimport matplotlib.pyplot as plt\nimport numpy as np\n\n\n# Theme tokens\nTHEME = os.getenv(\"ANYPLOT_THEME\", \"light\")\nPAGE_BG = \"#FAF8F1\" if THEME == \"light\" else \"#1A1A17\"\nINK = \"#1A1A17\" if THEME == \"light\" else \"#F0EFE8\"\nINK_SOFT = \"#4A4A44\" if THEME == \"light\" else \"#B8B7B0\"\nBRAND = \"#009E73\"\n\n# Data - Hourly temperature pattern (24-hour cycle)\nnp.random.seed(42)\nhours = np.arange(24)\ntheta = hours * (2 * np.pi / 24)\n\nbase_temp = 15 + 8 * np.sin(theta - np.pi / 2)  # Peak at 3 PM (hour 15)\nnoise = np.random.randn(24) * 1.5\nradius = base_temp + noise\n\ntheta_closed = np.append(theta, theta[0])\nradius_closed = np.append(radius, radius[0])\n\n# Plot - Square format for polar chart (12x12 @ 300 dpi = 3600x3600 px)\nfig, ax = plt.subplots(figsize=(12, 12), subplot_kw={\"projection\": \"polar\"}, facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\n# Filled area from center to data for visual weight\nax.fill_between(theta_closed, 0, radius_closed, color=BRAND, alpha=0.18)\n\n# Connecting line showing the cyclical pattern\nax.plot(theta_closed, radius_closed, color=BRAND, linewidth=3, alpha=0.9, zorder=2)\n\n# Scatter points for individual hourly readings\nax.scatter(theta, radius, s=280, color=BRAND, alpha=0.95, zorder=3, edgecolors=PAGE_BG, linewidth=1.5)\n\n# Configure angular axis (hours of day, midnight at top, clockwise)\nax.set_theta_zero_location(\"N\")\nax.set_theta_direction(-1)\nhour_labels = [\"12 AM\", \"3 AM\", \"6 AM\", \"9 AM\", \"12 PM\", \"3 PM\", \"6 PM\", \"9 PM\"]\nax.set_xticks(np.linspace(0, 2 * np.pi, 8, endpoint=False))\nax.set_xticklabels(hour_labels, fontsize=18)\n\n# Configure radial axis (temperature)\nax.set_ylim(0, 30)\nax.set_yticks([5, 10, 15, 20, 25])\nax.set_yticklabels([\"5°C\", \"10°C\", \"15°C\", \"20°C\", \"25°C\"], fontsize=16)\nax.set_rlabel_position(67.5)\n\n# Theme-adaptive styling\nax.set_title(\n    \"Hourly Temperature Pattern · polar-basic · matplotlib · anyplot.ai\",\n    fontsize=24,\n    pad=25,\n    fontweight=\"medium\",\n    color=INK,\n)\nax.grid(True, alpha=0.15, linewidth=1.0, color=INK)\nax.spines[\"polar\"].set_color(INK_SOFT)\nax.tick_params(colors=INK_SOFT, labelcolor=INK_SOFT)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=300, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}