{"spec_id":"line-markers","library":"altair","language":"python","code":"\"\"\" anyplot.ai\nline-markers: Line Plot with Markers\nLibrary: altair 6.1.0 | Python 3.13.13\nQuality: 90/100 | Created: 2026-05-12\n\"\"\"\n\nimport os\nimport sys\n\nimport numpy as np\nimport pandas as pd\n\n\n# Handle import shadowing: remove current dir from path temporarily\ncurrent_dir = os.path.dirname(os.path.abspath(__file__))\nsys.path = [p for p in sys.path if os.path.abspath(p) != current_dir]\n\nimport altair as alt\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\"\n\nIMPRINT = [\"#009E73\", \"#C475FD\", \"#4467A3\", \"#BD8233\"]\n\n# Data: Quality control measurements over time (sparse dataset where each point matters)\nnp.random.seed(42)\ntimes = np.array([1, 3, 6, 9, 12, 15, 18, 22, 26, 30])\nbatch_a = 99.2 + np.random.normal(0, 1.5, len(times))\nbatch_b = 98.8 + np.random.normal(0, 1.8, len(times))\nbatch_c = 99.5 + np.random.normal(0, 1.2, len(times))\n\ndf = pd.DataFrame(\n    {\n        \"Time (hours)\": np.concatenate([times, times, times]),\n        \"Quality (%)\": np.concatenate([batch_a, batch_b, batch_c]),\n        \"Batch\": np.repeat([\"Batch A\", \"Batch B\", \"Batch C\"], len(times)),\n    }\n)\n\n# Plot\nbase_chart = alt.Chart(df).encode(\n    x=alt.X(\"Time (hours):Q\", title=\"Time (hours)\"),\n    y=alt.Y(\"Quality (%):Q\", title=\"Quality (%)\"),\n    color=alt.Color(\"Batch:N\", scale=alt.Scale(range=IMPRINT[:3])),\n    strokeDash=alt.StrokeDash(\n        \"Batch:N\", scale=alt.Scale(domain=[\"Batch A\", \"Batch B\", \"Batch C\"], range=[[], [5, 5], [2, 2]])\n    ),\n)\n\nline_chart = base_chart.mark_line(size=3) + base_chart.mark_point(size=150)\n\nchart = (\n    line_chart.properties(\n        width=1600, height=900, background=PAGE_BG, title=alt.Title(\"line-markers · altair · anyplot.ai\", fontSize=28)\n    )\n    .configure_view(fill=PAGE_BG, stroke=INK_SOFT)\n    .configure_axis(\n        domainColor=INK_SOFT,\n        tickColor=INK_SOFT,\n        gridColor=INK,\n        gridOpacity=0.10,\n        labelColor=INK_SOFT,\n        titleColor=INK,\n        labelFontSize=18,\n        titleFontSize=22,\n    )\n    .configure_title(color=INK)\n    .configure_legend(\n        fillColor=ELEVATED_BG,\n        strokeColor=INK_SOFT,\n        labelColor=INK_SOFT,\n        titleColor=INK,\n        labelFontSize=16,\n        titleFontSize=18,\n    )\n)\n\n# Save\nchart.save(f\"plot-{THEME}.png\", scale_factor=3.0)\nchart.save(f\"plot-{THEME}.html\")\n"}