{"spec_id":"errorbar-basic","library":"ggplot2","language":"r","code":"#' anyplot.ai\n#' errorbar-basic: Basic Error Bar Plot\n#' Library: ggplot2 3.5.1 | R 4.4.1\n#' Quality: 90/100 | Created: 2026-06-30\n\nlibrary(ggplot2)\nlibrary(ragg)\n\n# Theme tokens — Imprint palette, 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\"\n\nIMPRINT_PALETTE <- c(\n    \"#009E73\",  # 1 — brand green (first series)\n    \"#C475FD\",  # 2 — lavender\n    \"#4467A3\",  # 3 — blue\n    \"#BD8233\",  # 4 — ochre\n    \"#AE3030\",  # 5 — matte red\n    \"#2ABCCD\",  # 6 — cyan\n    \"#954477\",  # 7 — rose\n    \"#99B314\"   # 8 — lime\n)\n\n# Data: enzyme activity across temperature conditions (mean ± 1 SD, n = 12 replicates)\nconditions    <- c(\"20°C\", \"25°C\", \"30°C\", \"35°C\", \"40°C\", \"45°C\", \"50°C\")\nmean_activity <- c(12.4, 18.7, 27.3, 35.6, 28.4, 19.1, 8.3)\nsd_activity   <- c(1.8,  2.1,  2.9,  3.2,  2.7,  1.9,  1.4)\n\ndf <- data.frame(\n    temperature = factor(conditions, levels = conditions),\n    mean_act    = mean_activity,\n    lower       = mean_activity - sd_activity,\n    upper       = mean_activity + sd_activity\n)\n\n# Plot\np <- ggplot(df, aes(x = temperature, y = mean_act)) +\n    geom_errorbar(\n        aes(ymin = lower, ymax = upper),\n        width     = 0.22,\n        linewidth = 1.0,\n        color     = IMPRINT_PALETTE[1]\n    ) +\n    geom_point(\n        size  = 3.5,\n        color = IMPRINT_PALETTE[1]\n    ) +\n    # Enlarged marker highlights the enzyme optimum at 35°C\n    geom_point(\n        data  = df[df$temperature == \"35°C\", ],\n        size  = 6.0,\n        color = IMPRINT_PALETTE[1]\n    ) +\n    # Focal-point annotation at enzyme optimum\n    annotate(\n        \"text\",\n        x     = 4,\n        y     = 40.5,\n        label = \"enzyme optimum\",\n        color = INK_SOFT,\n        size  = 3.2,\n        hjust = 0.5\n    ) +\n    scale_y_continuous(expand = expansion(mult = c(0.05, 0.13))) +\n    labs(\n        x       = \"Temperature\",\n        y       = \"Enzyme Activity (μmol / min)\",\n        title   = \"errorbar-basic · r · ggplot2 · anyplot.ai\",\n        caption = \"Error bars: ±1 SD  (n = 12 replicates per condition)\"\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.border       = element_blank(),\n        panel.grid.major.y = element_line(\n            color     = grDevices::adjustcolor(INK_SOFT, alpha.f = 0.45),\n            linewidth = 0.4\n        ),\n        panel.grid.major.x = element_blank(),\n        panel.grid.minor   = element_blank(),\n        axis.line          = element_line(color = INK_SOFT, linewidth = 0.5),\n        axis.title         = element_text(color = INK,      size = 10),\n        axis.text          = element_text(color = INK_SOFT, size = 8),\n        plot.title         = element_text(color = INK,      size = 12),\n        plot.caption       = element_text(color = INK_SOFT, size = 7,  hjust = 0),\n        plot.margin        = margin(20, 24, 16, 20)\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"}