{"spec_id":"lollipop-basic","library":"ggplot2","language":"r","code":"#' anyplot.ai\n#' lollipop-basic: Basic Lollipop Chart\n#' Library: ggplot2 3.5.1 | R 4.4.1\n#' Quality: 90/100 | Created: 2026-07-01\n\nlibrary(ggplot2)\nlibrary(dplyr)\nlibrary(ragg)\n\nset.seed(42)\n\n# Theme tokens — Imprint palette (prompts/default-style-guide.md)\nTHEME       <- Sys.getenv(\"ANYPLOT_THEME\", \"light\")\nPAGE_BG     <- if (THEME == \"light\") \"#FAF8F1\" else \"#1A1A17\"\nELEVATED_BG <- if (THEME == \"light\") \"#FFFDF6\" else \"#242420\"\nINK         <- if (THEME == \"light\") \"#1A1A17\" else \"#F0EFE8\"\nINK_SOFT    <- if (THEME == \"light\") \"#4A4A44\" else \"#B8B7B0\"\nRULE        <- if (THEME == \"light\") \"#1A1A1726\" else \"#F0EFE826\"\nIMPRINT_PALETTE <- c(\n  \"#009E73\", \"#C475FD\", \"#4467A3\", \"#BD8233\",\n  \"#AE3030\", \"#2ABCCD\", \"#954477\", \"#99B314\"\n)\nBRAND <- IMPRINT_PALETTE[1]\n\n# Data — aerobic fitness index by sport discipline (12 disciplines, sorted)\ndisciplines <- c(\n  \"Triathlon\", \"Running\", \"Gymnastics\", \"Swimming\", \"Rowing\",\n  \"Cycling\", \"Soccer\", \"Skiing\", \"Basketball\", \"Tennis\",\n  \"Volleyball\", \"Hiking\"\n)\nscores <- c(94, 91, 89, 87, 85, 83, 80, 78, 76, 74, 71, 67)\n\ndf <- data.frame(discipline = disciplines, score = scores) |>\n  arrange(score) |>\n  mutate(discipline = factor(discipline, levels = discipline))\n\nbaseline <- 60\n\n# Plot — horizontal lollipop; stems extend from baseline to score value\np <- ggplot(df, aes(x = score, y = discipline)) +\n  geom_segment(\n    aes(x = baseline, xend = score, y = discipline, yend = discipline),\n    color     = INK_SOFT,\n    linewidth = 0.7\n  ) +\n  geom_point(\n    color = BRAND,\n    size  = 5.0\n  ) +\n  geom_text(\n    aes(x = score + 0.8, label = score),\n    hjust  = 0,\n    color  = INK_SOFT,\n    size   = 2.5\n  ) +\n  scale_x_continuous(\n    limits = c(baseline, 100),\n    breaks = seq(60, 100, 10),\n    expand = expansion(mult = c(0, 0.12))\n  ) +\n  labs(\n    x     = \"Aerobic Fitness Index\",\n    y     = NULL,\n    title = \"lollipop-basic · r · ggplot2 · anyplot.ai\"\n  ) +\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_line(color = RULE, linewidth = 0.3),\n    panel.grid.major.y  = element_blank(),\n    panel.grid.minor    = element_blank(),\n    axis.title.x        = element_text(color = INK, size = 10),\n    axis.text.x         = element_text(color = INK_SOFT, size = 8),\n    axis.text.y         = element_text(color = INK_SOFT, size = 8),\n    plot.title          = element_text(color = INK, size = 12),\n    plot.title.position = \"plot\",\n    plot.margin         = margin(12, 16, 12, 8),\n    axis.line.x         = element_line(color = INK_SOFT, linewidth = 0.5),\n    axis.line.y         = element_blank(),\n    axis.ticks          = element_blank()\n  )\n\n# Save — ragg device for correct PNG output in CI\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"}