{"spec_id":"line-basic","library":"plotnine","language":"python","code":"\"\"\" anyplot.ai\nline-basic: Basic Line Plot\nLibrary: plotnine 0.15.3 | Python 3.13.13\nQuality: 89/100 | Updated: 2026-04-29\n\"\"\"\n\nimport os\nimport sys\n\n\n# Prevent this file from shadowing the plotnine library when run from its own directory\nsys.path = [p for p in sys.path if not p or os.path.abspath(p) != os.path.abspath(os.path.dirname(__file__))]\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_line,\n    geom_point,\n    ggplot,\n    labs,\n    scale_x_continuous,\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\"\n\n# Data - Monthly average temperature readings for a typical year\nnp.random.seed(42)\nmonths = np.arange(1, 13)\nbase_temp = np.array([5, 7, 11, 15, 19, 23, 26, 25, 21, 15, 10, 6])\ntemperature = base_temp + np.random.randn(12) * 1.5\n\ndf = pd.DataFrame({\"Month\": months, \"Temperature\": temperature})\n\nmonth_labels = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n\n# Plot\nplot = (\n    ggplot(df, aes(x=\"Month\", y=\"Temperature\"))\n    + geom_line(size=2.5, color=BRAND)\n    + geom_point(size=6, color=BRAND)\n    + scale_x_continuous(breaks=list(range(1, 13)), labels=month_labels)\n    + labs(x=\"Month\", y=\"Temperature (°C)\", title=\"line-basic · plotnine · anyplot.ai\")\n    + theme_minimal()\n    + 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        text=element_text(size=14, color=INK),\n        axis_title=element_text(size=20, color=INK),\n        axis_text=element_text(size=16, color=INK_SOFT),\n        plot_title=element_text(size=24, color=INK),\n        panel_grid_major=element_line(color=INK_SOFT, size=0.3, alpha=0.15),\n        panel_grid_minor=element_line(color=INK_SOFT, size=0.2, alpha=0.05),\n    )\n)\n\nplot.save(f\"plot-{THEME}.png\", dpi=300, verbose=False)\n"}