{"spec_id":"polar-line","library":"matplotlib","language":"python","code":"\"\"\" anyplot.ai\npolar-line: Polar Line Plot\nLibrary: matplotlib 3.10.9 | Python 3.13.13\nQuality: 97/100 | Updated: 2026-05-12\n\"\"\"\n\nimport os\nimport sys\n\n\n# Remove current directory from sys.path to avoid import conflict with matplotlib.py\nsys.path = [p for p in sys.path if os.path.abspath(p) != os.getcwd()]\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\"\nELEVATED_BG = \"#FFFDF6\" if THEME == \"light\" else \"#242420\"\nINK = \"#1A1A17\" if THEME == \"light\" else \"#F0EFE8\"\nINK_SOFT = \"#4A4A44\" if THEME == \"light\" else \"#B8B7B0\"\nBRAND = \"#009E73\"\nACCENT = \"#C475FD\"\n\n# Data - Simulating hourly temperature patterns for two seasons\nnp.random.seed(42)\n\n# Hours of day (24 hours = full circle)\nhours = np.linspace(0, 2 * np.pi, 25)[:-1]\n\n# Summer temperature pattern (warmer during day)\nsummer_temps = 20 + 8 * np.sin(hours - np.pi / 2) + np.random.randn(24) * 0.5\n\n# Winter temperature pattern (cooler, smaller amplitude)\nwinter_temps = 5 + 5 * np.sin(hours - np.pi / 2) + np.random.randn(24) * 0.5\n\n# Close the loop by appending first point\nhours_closed = np.append(hours, hours[0])\nsummer_closed = np.append(summer_temps, summer_temps[0])\nwinter_closed = np.append(winter_temps, winter_temps[0])\n\n# Plot\nfig, ax = plt.subplots(figsize=(12, 12), subplot_kw={\"projection\": \"polar\"}, facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\nax.plot(hours_closed, summer_closed, linewidth=3, color=BRAND, label=\"Summer\", marker=\"o\", markersize=8)\nax.plot(hours_closed, winter_closed, linewidth=3, color=ACCENT, label=\"Winter\", marker=\"o\", markersize=8)\n\n# Configure theta axis (hours of day)\nhour_labels = [f\"{h}:00\" for h in range(0, 24, 3)]\nax.set_xticks(np.linspace(0, 2 * np.pi, 8, endpoint=False))\nax.set_xticklabels(hour_labels, fontsize=16, color=INK_SOFT)\n\n# Configure radial axis (temperature)\nax.set_ylim(0, 35)\nax.set_yticks([0, 10, 20, 30])\nax.set_yticklabels([\"0°C\", \"10°C\", \"20°C\", \"30°C\"], fontsize=14, color=INK_SOFT)\n\n# Style\nax.set_title(\"polar-line · matplotlib · anyplot.ai\", fontsize=24, fontweight=\"medium\", color=INK, pad=40)\nax.set_rlabel_position(45)\n\nleg = ax.legend(loc=\"upper left\", bbox_to_anchor=(0.95, 0.95), fontsize=16)\nif leg:\n    leg.get_frame().set_facecolor(ELEVATED_BG)\n    leg.get_frame().set_edgecolor(INK_SOFT)\n    leg.get_frame().set_linewidth(0.5)\n    for text in leg.get_texts():\n        text.set_color(INK_SOFT)\n\nax.grid(True, alpha=0.15, linewidth=0.8, color=INK)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=300, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}