{"spec_id":"polar-line","library":"seaborn","language":"python","code":"\"\"\" anyplot.ai\npolar-line: Polar Line Plot\nLibrary: seaborn 0.13.2 | Python 3.13.13\nQuality: 94/100 | Updated: 2026-05-12\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\nIMPRINT = [\"#009E73\", \"#C475FD\", \"#4467A3\", \"#BD8233\", \"#AE3030\", \"#2ABCCD\", \"#954477\"]\n\n# Configure seaborn theme with theme-adaptive colors\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.10,\n        \"legend.facecolor\": ELEVATED_BG,\n        \"legend.edgecolor\": INK_SOFT,\n    },\n)\n\n# Data - Wind speeds by compass direction (8 directions, two wind patterns)\nnp.random.seed(42)\nangles = np.linspace(0, 2 * np.pi, 8, endpoint=False)\n\n# Pattern 1: Prevailing winds (stronger from one direction)\nprevailing = 12 + 6 * np.sin(angles) + np.random.randn(8) * 0.3\n\n# Pattern 2: Secondary wind pattern (different characteristic)\nsecondary = 8 + 4 * np.sin(angles + np.pi / 2) + np.random.randn(8) * 0.3\n\n# Close the loop for continuous lines\nangles_closed = np.append(angles, angles[0])\nprevailing_closed = np.append(prevailing, prevailing[0])\nsecondary_closed = np.append(secondary, secondary[0])\n\n# Create polar plot (square format for circular plot)\nfig, ax = plt.subplots(figsize=(12, 12), subplot_kw={\"projection\": \"polar\"}, facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\n# Plot lines\nax.plot(\n    angles_closed,\n    prevailing_closed,\n    linewidth=3.5,\n    color=IMPRINT[0],\n    label=\"Prevailing Winds\",\n    marker=\"o\",\n    markersize=12,\n    alpha=0.9,\n)\nax.plot(\n    angles_closed,\n    secondary_closed,\n    linewidth=3.5,\n    color=IMPRINT[1],\n    label=\"Secondary Pattern\",\n    marker=\"s\",\n    markersize=10,\n    alpha=0.9,\n)\n\n# Configure theta axis (compass directions)\ndirections = [\"N\", \"NE\", \"E\", \"SE\", \"S\", \"SW\", \"W\", \"NW\"]\nax.set_xticks(angles)\nax.set_xticklabels(directions, fontsize=18, color=INK_SOFT)\n\n# Configure radial axis (wind speed in m/s)\nax.set_ylim(0, 20)\nax.set_yticks([5, 10, 15, 20])\nax.set_yticklabels([\"5\", \"10\", \"15\", \"20\"], fontsize=16, color=INK_SOFT)\n\n# Title and legend\nax.set_title(\n    \"Wind Speed by Direction · polar-line · seaborn · anyplot.ai\", fontsize=24, pad=30, fontweight=\"medium\", color=INK\n)\n\nax.legend(loc=\"upper right\", bbox_to_anchor=(1.15, 1.05), fontsize=18, frameon=True)\n\n# Grid styling\nax.grid(True, alpha=0.15, linestyle=\"-\", linewidth=0.8)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=300, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}