{"spec_id":"line-markers","library":"plotnine","language":"python","code":"\"\"\" anyplot.ai\nline-markers: Line Plot with Markers\nLibrary: plotnine 0.15.4 | Python 3.13.13\nQuality: 90/100 | Updated: 2026-05-12\n\"\"\"\n\nimport os\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_color_manual,\n    scale_shape_manual,\n    theme,\n    theme_minimal,\n)\n\n\n# Theme colors\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\n# Okabe-Ito palette\nIMPRINT = [\"#009E73\", \"#C475FD\"]\n\n# Data: Monthly temperature readings from two weather stations\nnp.random.seed(42)\nmonths = np.arange(1, 13)\nmonth_labels = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n\n# Station A: Coastal location (milder temperatures)\nstation_a = np.array([8, 9, 12, 15, 19, 23, 26, 26, 22, 17, 12, 9]) + np.random.randn(12) * 0.5\n\n# Station B: Inland location (more extreme temperatures)\nstation_b = np.array([2, 4, 10, 16, 21, 26, 29, 28, 22, 14, 7, 3]) + np.random.randn(12) * 0.5\n\ndf = pd.DataFrame(\n    {\n        \"Month\": month_labels * 2,\n        \"Month_Num\": list(months) * 2,\n        \"Temperature\": np.concatenate([station_a, station_b]),\n        \"Station\": [\"Coastal Station\"] * 12 + [\"Inland Station\"] * 12,\n    }\n)\n\nanyplot_theme = 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, color=PAGE_BG),\n    panel_grid_major=element_line(color=INK, size=0.3, alpha=0.10),\n    panel_grid_minor=element_line(color=INK, size=0.2, alpha=0.05),\n    panel_border=element_rect(color=INK_SOFT, fill=None, size=0.5),\n    axis_title=element_text(color=INK, size=20),\n    axis_text=element_text(color=INK_SOFT, size=16),\n    axis_line=element_line(color=INK_SOFT, size=0.4),\n    plot_title=element_text(color=INK, size=24, face=\"bold\"),\n    legend_background=element_rect(fill=ELEVATED_BG, color=INK_SOFT, size=0.4),\n    legend_text=element_text(color=INK_SOFT, size=16),\n    legend_title=element_text(color=INK, size=18),\n    legend_position=\"right\",\n    text=element_text(size=14),\n)\n\n# Plot\nplot = (\n    ggplot(df, aes(x=\"Month_Num\", y=\"Temperature\", color=\"Station\", shape=\"Station\"))\n    + geom_line(size=1.5, alpha=0.85)\n    + geom_point(size=5, alpha=0.9)\n    + scale_color_manual(values=IMPRINT)\n    + scale_shape_manual(values=[\"o\", \"s\"])\n    + labs(\n        x=\"Month\",\n        y=\"Temperature (°C)\",\n        title=\"Temperature Comparison: Coastal vs Inland Stations\",\n        color=\"Weather Station\",\n        shape=\"Weather Station\",\n    )\n    + theme_minimal()\n    + anyplot_theme\n)\n\nplot.save(f\"plot-{THEME}.png\", dpi=300, verbose=False)\n"}