{"spec_id":"line-basic","library":"ggplot2","language":"r","code":"#' anyplot.ai\n#' line-basic: Basic Line Plot\n#' Library: ggplot2 4.0.3 | R 4.6.1\n#' Quality: 82/100 | Updated: 2026-10-29\n\nlibrary(ggplot2)\nlibrary(ragg)\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\"\nIMPRINT_PALETTE <- c(\"#009E73\", \"#C475FD\", \"#4467A3\", \"#BD8233\",\n                     \"#AE3030\", \"#2ABCCD\", \"#954477\", \"#99B314\")\n\n# Columns: set these to your table's column names\nDAY         <- \"Day of Season\"     # role: x\nTEMPERATURE <- \"Temperature (°C)\"  # role: y\n\n# Data: replace this block with your own table, for example df <- read.csv(\"temperature.csv\", check.names = FALSE)\nset.seed(42)\nn_days <- 90\nday_of_season <- 1:n_days\nseasonal_curve <- 24 + 6 * sin(pi * day_of_season / n_days)\ndf <- tibble::tibble(\n  !!DAY         := day_of_season,\n  !!TEMPERATURE := seasonal_curve + rnorm(n_days, mean = 0, sd = 0.7)\n)\n\n# Plot: reads only df and the constants above\np <- ggplot(df, aes(x = .data[[DAY]], y = .data[[TEMPERATURE]])) +\n  geom_line(color = IMPRINT_PALETTE[1], linewidth = 1.5) +\n  labs(\n    title = \"line-basic · r · ggplot2 · anyplot.ai\",\n    x = DAY,\n    y = TEMPERATURE\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\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"}