{"spec_id":"point-basic","library":"plotly","language":"python","code":"\"\"\" anyplot.ai\npoint-basic: Point Estimate Plot\nLibrary: plotly 6.7.0 | Python 3.13.13\nQuality: 86/100 | Updated: 2026-05-11\n\"\"\"\n\nimport os\n\nimport numpy as np\nimport plotly.graph_objects as go\n\n\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\"\nGRID = \"rgba(26,26,23,0.10)\" if THEME == \"light\" else \"rgba(240,239,232,0.10)\"\nBRAND = \"#009E73\"  # Okabe-Ito position 1\n\n# Data - Treatment effects for different interventions\nnp.random.seed(42)\ncategories = [\"Control\", \"Treatment A\", \"Treatment B\", \"Treatment C\", \"Treatment D\", \"Treatment E\"]\n\n# Generate realistic point estimates with varying confidence intervals\nestimates = [0.0, 2.3, 3.8, 1.5, 4.2, 2.9]\n# CI widths vary by sample size/variance\nci_widths = [0.8, 1.2, 0.9, 1.5, 1.1, 1.3]\nlower = [e - w for e, w in zip(estimates, ci_widths, strict=False)]\nupper = [e + w for e, w in zip(estimates, ci_widths, strict=False)]\n\n# Create figure\nfig = go.Figure()\n\n# Add error bars (horizontal orientation)\nfig.add_trace(\n    go.Scatter(\n        x=estimates,\n        y=categories,\n        mode=\"markers\",\n        marker={\"size\": 18, \"color\": BRAND, \"symbol\": \"circle\"},\n        error_x={\n            \"type\": \"data\",\n            \"symmetric\": False,\n            \"array\": [u - e for e, u in zip(estimates, upper, strict=False)],\n            \"arrayminus\": [e - low for e, low in zip(estimates, lower, strict=False)],\n            \"color\": BRAND,\n            \"thickness\": 3,\n            \"width\": 10,\n        },\n        name=\"Estimate ± 95% CI\",\n        showlegend=True,\n    )\n)\n\n# Add reference line at zero (null hypothesis)\nfig.add_vline(\n    x=0,\n    line={\"color\": INK_SOFT, \"width\": 3, \"dash\": \"dash\"},\n    annotation_text=\"Null\",\n    annotation_position=\"top\",\n    annotation_font={\"size\": 18, \"color\": INK_SOFT},\n)\n\n# Layout\nfig.update_layout(\n    title={\n        \"text\": \"point-basic · plotly · anyplot.ai\",\n        \"font\": {\"size\": 32, \"color\": INK},\n        \"x\": 0.5,\n        \"xanchor\": \"center\",\n    },\n    xaxis={\n        \"title\": {\"text\": \"Effect Size (units)\", \"font\": {\"size\": 24, \"color\": INK}},\n        \"tickfont\": {\"size\": 18, \"color\": INK_SOFT},\n        \"zeroline\": False,\n        \"gridcolor\": GRID,\n        \"gridwidth\": 1,\n        \"linecolor\": INK_SOFT,\n        \"zerolinecolor\": INK_SOFT,\n    },\n    yaxis={\n        \"title\": {\"text\": \"Treatment Group\", \"font\": {\"size\": 24, \"color\": INK}},\n        \"tickfont\": {\"size\": 20, \"color\": INK_SOFT},\n        \"gridcolor\": GRID,\n        \"gridwidth\": 1,\n        \"linecolor\": INK_SOFT,\n        \"zerolinecolor\": INK_SOFT,\n    },\n    paper_bgcolor=PAGE_BG,\n    plot_bgcolor=PAGE_BG,\n    font={\"color\": INK},\n    template=\"plotly_white\",\n    legend={\n        \"font\": {\"size\": 18, \"color\": INK_SOFT},\n        \"bgcolor\": ELEVATED_BG,\n        \"bordercolor\": INK_SOFT,\n        \"borderwidth\": 1,\n        \"x\": 0.98,\n        \"y\": 0.02,\n        \"xanchor\": \"right\",\n        \"yanchor\": \"bottom\",\n    },\n    margin={\"l\": 150, \"r\": 80, \"t\": 100, \"b\": 80},\n)\n\n# Save as PNG and HTML\nfig.write_image(f\"plot-{THEME}.png\", width=1600, height=900, scale=3)\nfig.write_html(f\"plot-{THEME}.html\", include_plotlyjs=\"cdn\")\n"}