{"spec_id":"point-basic","library":"plotnine","language":"python","code":"\"\"\" anyplot.ai\npoint-basic: Point Estimate Plot\nLibrary: plotnine 0.15.4 | Python 3.13.13\nQuality: 89/100 | Updated: 2026-05-11\n\"\"\"\n\nimport os\n\nimport numpy as np\nimport pandas as pd\nfrom plotnine import (\n    aes,\n    element_line,\n    element_rect,\n    element_text,\n    geom_errorbarh,\n    geom_point,\n    geom_vline,\n    ggplot,\n    labs,\n    theme,\n    theme_minimal,\n)\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\"  # Okabe-Ito position 1\n\n# Data: Product satisfaction scores with 95% confidence intervals\nnp.random.seed(42)\n\ncategories = [\n    \"Customer Service\",\n    \"Product Quality\",\n    \"Delivery Speed\",\n    \"Website Usability\",\n    \"Price Value\",\n    \"Return Process\",\n    \"Product Variety\",\n    \"Packaging\",\n]\n\n# Generate realistic satisfaction scores (1-10 scale) with varying uncertainty\nestimates = np.array([7.8, 8.2, 6.5, 7.1, 6.9, 7.4, 8.0, 7.6])\n# Confidence intervals vary by sample size/variance\nci_widths = np.array([0.8, 0.5, 1.2, 0.9, 1.0, 0.7, 0.6, 0.4])\n\ndf = pd.DataFrame(\n    {\"category\": categories, \"estimate\": estimates, \"lower\": estimates - ci_widths, \"upper\": estimates + ci_widths}\n)\n\n# Sort by estimate for better visualization\ndf = df.sort_values(\"estimate\").reset_index(drop=True)\ndf[\"category\"] = pd.Categorical(df[\"category\"], categories=df[\"category\"], ordered=True)\n\n# Plot\nanyplot_theme = theme(\n    figure_size=(16, 9),\n    plot_background=element_rect(fill=PAGE_BG, color=PAGE_BG),\n    panel_background=element_rect(fill=PAGE_BG),\n    panel_grid_major=element_line(color=INK_SOFT, size=0.3, linewidth=0.3),\n    panel_grid_minor=element_line(linewidth=0),\n    panel_border=element_rect(color=INK_SOFT, fill=None),\n    axis_title=element_text(color=INK, size=20),\n    axis_text=element_text(color=INK_SOFT, size=16),\n    axis_line=element_line(color=INK_SOFT, size=0.5),\n    plot_title=element_text(color=INK, size=24, weight=\"bold\"),\n    legend_background=element_rect(fill=PAGE_BG, color=INK_SOFT),\n    legend_text=element_text(color=INK_SOFT, size=16),\n    legend_title=element_text(color=INK, size=16),\n)\n\nplot = (\n    ggplot(df, aes(x=\"estimate\", y=\"category\"))\n    + geom_vline(xintercept=7.0, linetype=\"dashed\", color=INK_SOFT, size=0.8)\n    + geom_errorbarh(aes(xmin=\"lower\", xmax=\"upper\"), height=0.3, size=1.5, color=BRAND)\n    + geom_point(size=5, color=BRAND)\n    + labs(x=\"Satisfaction Score (1-10)\", y=\"Category\", title=\"point-basic · plotnine · anyplot.ai\")\n    + theme_minimal()\n    + anyplot_theme\n)\n\n# Save\nplot.save(f\"plot-{THEME}.png\", dpi=300)\n"}