{"spec_id":"line-filled","library":"bokeh","language":"python","code":"\"\"\" anyplot.ai\nline-filled: Filled Line Plot\nLibrary: bokeh 3.9.0 | Python 3.13.13\nQuality: 91/100 | Updated: 2026-05-12\n\"\"\"\n\nimport os\nimport time\nfrom pathlib import Path\n\nimport numpy as np\nfrom bokeh.io import output_file, save\nfrom bokeh.models import ColumnDataSource, HoverTool\nfrom bokeh.plotting import figure\nfrom selenium import webdriver\nfrom selenium.webdriver.chrome.options import Options\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 - Monthly website traffic over a year\nnp.random.seed(42)\nmonths = np.arange(1, 13)\n# Simulate traffic with seasonal trend (higher in summer/winter holidays)\nbase_traffic = 50000\nseasonal = 15000 * np.sin(2 * np.pi * (months - 3) / 12)  # Peak in summer\ntrend = 2000 * months  # Gradual growth\nnoise = np.random.normal(0, 3000, 12)\ntraffic = base_traffic + seasonal + trend + noise\ntraffic = np.maximum(traffic, 0)  # Ensure positive values\n\n# Create ColumnDataSource\nsource = ColumnDataSource(data={\"month\": months, \"traffic\": traffic, \"traffic_zero\": np.zeros(len(months))})\n\n# Create figure\np = figure(\n    width=4800,\n    height=2700,\n    title=\"line-filled · bokeh · anyplot.ai\",\n    x_axis_label=\"Month\",\n    y_axis_label=\"Website Visitors (count)\",\n)\n\n# Filled area using varea\np.varea(x=\"month\", y1=\"traffic_zero\", y2=\"traffic\", source=source, fill_color=BRAND, fill_alpha=0.35)\n\n# Line on top of the fill\np.line(x=\"month\", y=\"traffic\", source=source, line_color=BRAND, line_width=4)\n\n# Add points for visual emphasis\np.scatter(x=\"month\", y=\"traffic\", source=source, size=12, color=BRAND, fill_alpha=0.8)\n\n# Add hover tool\nhover = HoverTool(tooltips=[(\"Month\", \"@month\"), (\"Visitors\", \"@traffic{0,0}\")])\np.add_tools(hover)\n\n# Styling for large canvas\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 text colors\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\n\n# Grid styling\np.xgrid.grid_line_alpha = 0.10\np.ygrid.grid_line_alpha = 0.10\np.xgrid.grid_line_color = INK\np.ygrid.grid_line_color = INK\n\n# Axis styling\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\n# Background\np.background_fill_color = PAGE_BG\np.border_fill_color = PAGE_BG\np.outline_line_color = INK_SOFT\n\n# X-axis ticks for each month\np.xaxis.ticker = list(range(1, 13))\n\n# Save as interactive HTML\noutput_file(f\"plot-{THEME}.html\")\nsave(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)\n\ndriver = webdriver.Chrome(options=opts)\ndriver.set_window_size(W, H)\ndriver.get(f\"file://{Path(f'plot-{THEME}.html').resolve()}\")\ntime.sleep(3)  # Let bokeh's JS render the canvas\ndriver.save_screenshot(f\"plot-{THEME}.png\")\ndriver.quit()\n"}