{"spec_id":"line-basic","library":"ggplot2","language":"r","code":"#' anyplot.ai\n#' line-basic: Basic Line Plot\n#' Library: ggplot2 3.5.1 | R 4.4.1\n#' Quality: 90/100 | Created: 2026-08-24\n\nlibrary(ggplot2)\nlibrary(ragg)\n\nset.seed(42)\n\n# --- Theme tokens (see prompts/default-style-guide.md \"Theme-adaptive Chrome\")\nTHEME    <- Sys.getenv(\"ANYPLOT_THEME\", \"light\")\nPAGE_BG  <- if (THEME == \"light\") \"#FAF8F1\" else \"#1A1A17\"\nINK      <- if (THEME == \"light\") \"#1A1A17\" else \"#F0EFE8\"\nINK_SOFT <- if (THEME == \"light\") \"#4A4A44\" else \"#B8B7B0\"\nBRAND    <- \"#009E73\" # Imprint palette position 1 — ALWAYS first series\n\n# --- Data: daily temperature readings across a 90-day summer season --------\nn_days <- 90\nday_of_season <- 1:n_days\nseasonal_curve <- 24 + 6 * sin(pi * day_of_season / n_days)\ndaily_temp_c <- seasonal_curve + rnorm(n_days, mean = 0, sd = 0.7)\n\ndf <- tibble::tibble(day = day_of_season, temperature = daily_temp_c)\n\n# Seasonal peak — the single hottest observed reading — anchors a focal\n# annotation that tells the rise-then-fall story.\npeak_day  <- day_of_season[which.max(daily_temp_c)]\npeak_temp <- max(daily_temp_c)\npeak_df   <- tibble::tibble(day = peak_day, temperature = peak_temp)\n\n# --- Plot --------------------------------------------------------------------\nplot_title <- \"line-basic · r · ggplot2 · anyplot.ai\"\n\np <- ggplot(df, aes(x = day, y = temperature)) +\n  geom_smooth(\n    se = FALSE, method = \"loess\", formula = y ~ x,\n    color = INK_SOFT, linewidth = 0.6, linetype = \"dashed\"\n  ) +\n  geom_line(color = BRAND, linewidth = 1.5) +\n  geom_point(data = peak_df, color = BRAND, size = 2.3) +\n  annotate(\n    \"text\", x = peak_day - 4, y = peak_temp + 1.1,\n    label = sprintf(\"Peak: %.1f°C\", peak_temp),\n    color = INK_SOFT, size = 3, fontface = \"italic\", hjust = 0.5\n  ) +\n  labs(\n    title = plot_title,\n    x = \"Day of Season\",\n    y = \"Temperature (°C)\"\n  ) +\n  scale_x_continuous(expand = expansion(mult = c(0.01, 0.02))) +\n  theme_minimal(base_size = 8) +\n  theme(\n    plot.background   = element_rect(fill = PAGE_BG, color = PAGE_BG),\n    panel.background  = element_rect(fill = PAGE_BG, color = NA),\n    panel.grid.major.x = element_blank(),\n    panel.grid.minor.x = element_blank(),\n    panel.grid.minor.y = element_blank(),\n    panel.grid.major.y = element_line(color = INK, linewidth = 0.2),\n    axis.title         = element_text(color = INK, size = 10),\n    axis.text          = element_text(color = INK_SOFT, size = 8),\n    axis.ticks         = element_blank(),\n    plot.title         = element_text(color = INK, size = 12, face = \"bold\"),\n    plot.margin        = margin(12, 16, 8, 8)\n  )\n\n# --- Save (PNG, both themes) -------------------------------------------------\nggsave(\n  filename = sprintf(\"plot-%s.png\", THEME),\n  plot     = p,\n  device   = ragg::agg_png,\n  width    = 8,\n  height   = 4.5,\n  units    = \"in\",\n  dpi      = 400\n)\n"}