{"spec_id":"point-basic","library":"bokeh","language":"python","code":"\"\"\" anyplot.ai\npoint-basic: Point Estimate Plot\nLibrary: bokeh 3.9.0 | Python 3.13.13\nQuality: 92/100 | Updated: 2026-05-11\n\"\"\"\n\nimport os\nimport sys\nimport time\nfrom pathlib import Path\n\nimport numpy as np\nfrom selenium import webdriver\nfrom selenium.webdriver.chrome.options import Options\n\n\n# Avoid shadowing bokeh module - remove current directory from path\n_original_path = sys.path.copy()\nsys.path = [p for p in sys.path if p not in (\"\", \".\", str(Path(__file__).parent))]\n\ntry:\n    import bokeh.io as bk_io\n    import bokeh.models as bk_models\n    import bokeh.plotting as bk_plotting\nfinally:\n    sys.path = _original_path\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\"\nBRAND = \"#009E73\"\n\n# Data - Effect sizes for different treatment groups with 95% confidence intervals\nnp.random.seed(42)\ncategories = [\"Treatment A\", \"Treatment B\", \"Treatment C\", \"Treatment D\", \"Treatment E\", \"Control\"]\nestimates = np.array([2.5, 1.8, 3.2, -0.5, 1.2, 0.0])\nci_widths = np.array([0.8, 1.2, 0.6, 0.9, 1.5, 0.4])\nlower = estimates - ci_widths\nupper = estimates + ci_widths\n\n# Create ColumnDataSource\nsource = bk_models.ColumnDataSource(\n    data={\"categories\": categories, \"estimates\": estimates, \"lower\": lower, \"upper\": upper}\n)\n\n# Create figure with categorical y-axis (horizontal orientation)\np = bk_plotting.figure(\n    width=4800,\n    height=2700,\n    y_range=categories[::-1],\n    title=\"point-basic · bokeh · anyplot.ai\",\n    x_axis_label=\"Effect Size\",\n    y_axis_label=\"Treatment Group\",\n)\n\n# Add reference line at zero\nzero_line = bk_models.Span(location=0, dimension=\"height\", line_color=INK_SOFT, line_width=3, line_dash=\"dashed\")\np.add_layout(zero_line)\n\n# Add error bars with caps\nwhisker = bk_models.Whisker(\n    source=source,\n    base=\"categories\",\n    lower=\"lower\",\n    upper=\"upper\",\n    dimension=\"width\",\n    line_color=BRAND,\n    line_width=6,\n    upper_head=bk_models.TeeHead(size=30, line_color=BRAND, line_width=6),\n    lower_head=bk_models.TeeHead(size=30, line_color=BRAND, line_width=6),\n)\np.add_layout(whisker)\n\n# Plot points with larger markers\np.scatter(x=\"estimates\", y=\"categories\", source=source, size=40, color=BRAND, line_width=2, line_color=PAGE_BG)\n\n# Typography sizing\np.title.text_font_size = \"28pt\"\np.xaxis.axis_label_text_font_size = \"22pt\"\np.yaxis.axis_label_text_font_size = \"22pt\"\np.xaxis.major_label_text_font_size = \"18pt\"\np.yaxis.major_label_text_font_size = \"18pt\"\n\n# Theme-adaptive colors\np.background_fill_color = PAGE_BG\np.border_fill_color = PAGE_BG\np.outline_line_color = INK_SOFT\n\np.title.text_color = INK\np.xaxis.axis_label_text_color = INK\np.yaxis.axis_label_text_color = INK\np.xaxis.major_label_text_color = INK_SOFT\np.yaxis.major_label_text_color = INK_SOFT\np.xaxis.axis_line_color = INK_SOFT\np.yaxis.axis_line_color = INK_SOFT\np.xaxis.major_tick_line_color = INK_SOFT\np.yaxis.major_tick_line_color = INK_SOFT\n\np.xgrid.grid_line_color = INK\np.xgrid.grid_line_alpha = 0.10\np.ygrid.grid_line_alpha = 0.0\n\n# Remove toolbar\np.toolbar_location = None\n\n# Save HTML\nbk_io.output_file(f\"plot-{THEME}.html\")\nbk_io.save(p)\n\n# Screenshot with headless Chrome\nW, H = 4800, 2700\nopts = Options()\nfor arg in (\n    \"--headless=new\",\n    \"--no-sandbox\",\n    \"--disable-dev-shm-usage\",\n    \"--disable-gpu\",\n    f\"--window-size={W},{H}\",\n    \"--hide-scrollbars\",\n):\n    opts.add_argument(arg)\ndriver = webdriver.Chrome(options=opts)\ndriver.set_window_size(W, H)\ndriver.get(f\"file://{Path(f'plot-{THEME}.html').resolve()}\")\ntime.sleep(3)\ndriver.save_screenshot(f\"plot-{THEME}.png\")\ndriver.quit()\n"}