{"spec_id":"pie-basic","library":"seaborn","language":"python","code":"\"\"\" anyplot.ai\npie-basic: Basic Pie Chart\nLibrary: seaborn 0.13.2 | Python 3.13.13\nQuality: 83/100 | Created: 2026-05-28\n\"\"\"\n\nimport os\n\nimport matplotlib.pyplot as plt\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\"\nINK_MUTED = \"#6B6A63\" if THEME == \"light\" else \"#A8A79F\"\n\n# seaborn palette API — set_palette registers the anyplot hues globally; color_palette\n# retrieves them as a seaborn ColorPalette object for direct indexing\nANYPLOT_HEX = [\"#009E73\", \"#C475FD\", \"#4467A3\", \"#BD8233\", \"#AE3030\", \"#2ABCCD\"]\n\nsns.set_theme(\n    style=\"ticks\",\n    rc={\n        \"figure.facecolor\": PAGE_BG,\n        \"axes.facecolor\": PAGE_BG,\n        \"axes.edgecolor\": INK_SOFT,\n        \"text.color\": INK,\n        \"legend.facecolor\": ELEVATED_BG,\n        \"legend.edgecolor\": INK_SOFT,\n    },\n)\nsns.set_palette(ANYPLOT_HEX)\npalette = sns.color_palette(ANYPLOT_HEX)  # ColorPalette object for slice color access\n\n# Data — global cloud computing market share (2024 estimates)\ncategories = [\"Amazon AWS\", \"Microsoft Azure\", \"Google Cloud\", \"Alibaba Cloud\", \"IBM Cloud\", \"Others\"]\nshares = [32, 22, 11, 6, 5, 24]\ncolors = list(palette[:5]) + [INK_MUTED]  # muted anchor for catch-all \"Others\"\nexplode = [0.06, 0, 0, 0, 0, 0]\n\n# Square canvas for symmetric donut chart\nfig, ax = plt.subplots(figsize=(6, 6), dpi=400, facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\nfig.subplots_adjust(top=0.88, bottom=0.14)\n\n# Donut chart — width=0.65 hollows the center; pctdistance=0.78 centers labels in the ring\nwedges, texts, autotexts = ax.pie(\n    shares,\n    labels=None,\n    colors=colors,\n    explode=explode,\n    autopct=\"%1.0f%%\",\n    pctdistance=0.78,\n    startangle=90,\n    wedgeprops={\"edgecolor\": PAGE_BG, \"linewidth\": 2.0, \"width\": 0.65},\n)\n\nfor autotext in autotexts:\n    autotext.set_fontsize(8)\n    autotext.set_color(INK)\n    autotext.set_fontweight(\"medium\")\n\n# Center annotation — market context label in the donut hole\nax.text(\n    0,\n    0,\n    \"Cloud\\nMarket\\n2024\",\n    ha=\"center\",\n    va=\"center\",\n    fontsize=9,\n    color=INK_SOFT,\n    fontweight=\"medium\",\n    linespacing=1.4,\n)\n\n# Title and legend\ntitle = \"pie-basic · python · seaborn · anyplot.ai\"\nax.set_title(title, fontsize=12, fontweight=\"bold\", color=INK, pad=14)\n\nlegend = ax.legend(\n    wedges,\n    categories,\n    loc=\"lower center\",\n    bbox_to_anchor=(0.5, -0.08),\n    ncol=3,\n    fontsize=8,\n    frameon=True,\n    facecolor=ELEVATED_BG,\n    edgecolor=INK_SOFT,\n)\nfor text in legend.get_texts():\n    text.set_color(INK_SOFT)\n\n# Save — do NOT use bbox_inches='tight' (seaborn canvas contract)\nplt.savefig(f\"plot-{THEME}.png\", dpi=400, facecolor=PAGE_BG)\n"}