{"spec_id":"line-filled","library":"ggplot2","language":"r","code":"#' anyplot.ai\n#' line-filled: Filled Line Plot\n#' Library: ggplot2 3.5.1 | R 4.4.1\n#' Quality: 88/100 | Created: 2026-09-05\n\nlibrary(ggplot2)\nlibrary(ragg)\n\nset.seed(42)\n\n# --- Theme tokens -----------------------------------------------------------\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\"\nIMPRINT_PALETTE <- c(\"#009E73\", \"#C475FD\", \"#4467A3\", \"#BD8233\",\n                     \"#AE3030\", \"#2ABCCD\", \"#954477\", \"#99B314\")\nBRAND <- IMPRINT_PALETTE[1]\n\n# --- Data ---------------------------------------------------------------\n# Daily page views for a product landing page over one month, with a\n# gradual ramp plus day-to-day noise and a weekend dip.\nday <- 1:30\nweekend_dip <- ifelse(day %% 7 %in% c(6, 0), -800, 0)\npage_views <- 4200 + 60 * day + weekend_dip + rnorm(30, mean = 0, sd = 350)\npage_views <- pmax(page_views, 0)\n\ndf <- tibble::tibble(day = day, page_views = page_views)\n\navg_views  <- mean(df$page_views)\npeak_idx   <- which.max(df$page_views)\npeak_day   <- df$day[peak_idx]\npeak_views <- df$page_views[peak_idx]\npeak_hjust <- if (peak_day > 25) 1 else if (peak_day < 5) 0 else 0.5\n\n# --- Plot -----------------------------------------------------------------\ntitle_text <- \"line-filled · r · ggplot2 · anyplot.ai\"\n\np <- ggplot(df, aes(x = day, y = page_views)) +\n  geom_area(fill = BRAND, alpha = 0.35) +\n  geom_hline(yintercept = avg_views, linetype = \"dashed\", color = INK_SOFT, linewidth = 0.4) +\n  geom_line(color = BRAND, linewidth = 1.4) +\n  geom_point(color = BRAND, size = 1.8, alpha = 0.85) +\n  annotate(\"point\", x = peak_day, y = peak_views, size = 3.5, color = BRAND) +\n  annotate(\n    \"text\", x = peak_day, y = peak_views, hjust = peak_hjust, vjust = -0.8,\n    label = sprintf(\"Peak: %s views (day %d)\", scales::label_comma()(round(peak_views)), peak_day),\n    color = INK, size = 3\n  ) +\n  annotate(\n    \"text\", x = 0.5, y = avg_views, hjust = 0, vjust = -0.6,\n    label = sprintf(\"Monthly avg: %s\", scales::label_comma()(round(avg_views))),\n    color = INK_SOFT, size = 2.6\n  ) +\n  scale_x_continuous(breaks = seq(0, 30, by = 5)) +\n  scale_y_continuous(labels = scales::label_comma(), limits = c(0, NA), expand = expansion(mult = c(0, 0.2))) +\n  coord_cartesian(clip = \"off\") +\n  labs(title = title_text, x = \"Day of Month\", y = \"Page Views\") +\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  = element_blank(),\n    panel.grid.major.y = element_line(color = INK, linewidth = 0.25),\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)\n  )\n\n# --- Save -------------------------------------------------------------------\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"}