{"spec_id":"bar-basic","library":"seaborn","language":"python","code":"\"\"\" anyplot.ai\nbar-basic: Basic Bar Chart\nLibrary: seaborn 0.13.2 | Python 3.13.13\nQuality: 86/100 | Updated: 2026-05-28\n\"\"\"\n\nimport os\n\nimport matplotlib.pyplot as plt\nimport pandas as pd\nimport seaborn as sns\n\n\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\"\nANYPLOT_AMBER = \"#DDCC77\"\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        \"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    },\n)\n\n# Data — average annual sunshine hours for major US cities\ndata = pd.DataFrame(\n    {\n        \"city\": [\"Phoenix\", \"Miami\", \"Denver\", \"Boston\", \"Chicago\", \"Portland\", \"Seattle\"],\n        \"sunshine_hours\": [3872, 3154, 3110, 2634, 2508, 2341, 2170],\n    }\n)\n\n# Highlight the Phoenix outlier with amber accent; all other bars stay brand green\npalette = {city: (ANYPLOT_AMBER if city == \"Phoenix\" else BRAND) for city in data[\"city\"]}\n\n# Plot\nfig, ax = plt.subplots(figsize=(8, 4.5), dpi=400, facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\nsns.barplot(data=data, x=\"city\", y=\"sunshine_hours\", hue=\"city\", palette=palette, legend=False, width=0.65, ax=ax)\n\n# Value labels on bars\nfor container in ax.containers:\n    ax.bar_label(container, fmt=\"%d\", fontsize=10, color=INK_SOFT, padding=3)\n\n# Style\nax.set_xlabel(\"City\", fontsize=10, color=INK)\nax.set_ylabel(\"Sunshine Hours per Year\", fontsize=10, color=INK)\ntitle = \"Annual Sunshine Hours · bar-basic · python · seaborn · anyplot.ai\"\nax.set_title(title, fontsize=12, fontweight=\"medium\", color=INK, pad=12)\nax.tick_params(axis=\"both\", labelsize=8, colors=INK_SOFT)\nsns.despine(ax=ax, top=True, right=True)\nax.spines[\"left\"].set_color(INK_SOFT)\nax.spines[\"bottom\"].set_color(INK_SOFT)\nax.yaxis.grid(True, alpha=0.15, linewidth=0.8, color=INK)\nax.set_axisbelow(True)\nax.set_ylim(0, data[\"sunshine_hours\"].max() * 1.12)\n\nfig.subplots_adjust(left=0.10, right=0.97, top=0.90, bottom=0.12)\nplt.savefig(f\"plot-{THEME}.png\", dpi=400, facecolor=PAGE_BG)\n"}