본문으로 건너뛰기
cccskills
무료GitHub에 공개

ggplot2

R visualization with ggplot2 grammar of graphics. Geoms, aesthetics, scales, facets, coords, themes. Extensions: patchwork, ggrepel, ggridges, ggdist. Use when execution language is R. Python equivalent: plotnine.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DAAF-Contribution-Community/daaf스타 238(GitHub 238 + cccskills 0)

실행 점수 미검증

설치 방법 보기

포함된 파일(8)

  • SKILL.md10.7 KB
  • references/extensions.md10.4 KB
  • references/facets.md5.3 KB
  • references/geoms.md8.5 KB
  • references/gotchas.md8.7 KB
  • references/quickstart.md4.8 KB
  • references/scales.md8.3 KB
  • references/themes.md10.7 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

ggplot2 Skill

R visualization with the grammar of graphics via ggplot2 4.0.x. Covers geoms (point, line, bar, histogram, boxplot, violin, ribbon, tile, text), aesthetics, scales, coordinates, facets, and themes. Extension packages: patchwork (multi-panel composition), ggrepel (non-overlapping text labels), ggridges (ridgeline density plots), ggdist (distribution visualization). Use when execution language is R and static publication-quality figures are needed. Python equivalent: plotnine (which ports ggplot2's grammar to Python). For interactive R charts, use plotly-r instead.

What is ggplot2?

ggplot2 is the grammar of graphics implementation for R:

  • Declarative: Describe what you want, not how to draw it
  • Layered: Build plots by adding components with +
  • The original: plotnine (Python) is a port of ggplot2, not the reverse
  • Publication-ready: Extensive themes and customization for polished output
  • Extensible: Hundreds of extension packages (patchwork, ggrepel, ggridges, ggdist)

Version Notes: ggplot2 4.0.x (Breaking Changes from 3.x)

ggplot2 4.0.0 is a major release with significant breaking changes. Code written for 3.x may need updates.

Critical: linewidth vs size for Lines

The size aesthetic for line-based geoms was deprecated in 3.4.0. In 4.0.x:

  • geom_line(size = 1) still works but throws a deprecation warning
  • geom_bar(size = 1) / geom_col(size = 1) silently ignores size (fallback removed)
  • Always use linewidth for lines, borders, and outlines
  • size remains correct for points only (geom_point(size = 3))
# WRONG (deprecated / ignored in 4.0)
geom_line(size = 1)
geom_bar(size = 0.5)

# CORRECT (4.0+)
geom_line(linewidth = 1)
geom_bar(linewidth = 0.5)

Other 4.0.x Breaking Changes

Change3.x Behavior4.0.x Behavior
S7 internalsS3 classesS7 classes (affects extension authors, not users)
coord_trans()Primary nameRenamed to coord_transform(); coord_trans() still works
theme_set() etc.Primary namesRenamed: set_theme(), get_theme(), update_theme(), replace_theme(); old names still work
geom_errorbarh()PrimaryDeprecated; use geom_errorbar(orientation = "y")
geom_violin(draw_quantiles)Geom parameterDeprecated; use geom_violin(quantiles = c(...), quantile.linetype = 1) — quantiles are hidden by default in 4.0, so quantile.linetype (a non-0 value) is required to display them
fatten argumentIn boxplot/crossbar/pointrangeDeprecated
borders()ActiveDeprecated; use annotation_borders()
Pre-3.0 deprecationsWarningsNow errors
Theme geom defaultsVia update_geom_defaults()New theme(geom = element_geom(...)) for global defaults
Binning defaultsOld boundary selectionBetter adherence to nbin argument; may change existing plots
mgcv, tibbleImportedMoved to Suggests upstream; both pre-installed in DAAF (no action needed)

New 4.0.x Features

  • theme(geom = element_geom(...)) for global geom aesthetic defaults
  • from_theme() inside aes() to reference theme defaults
  • stat_connect() and stat_manual() new stats
  • theme(panel.widths, panel.heights) for panel sizing
  • labs(dictionary = ...) for label mapping by variable name
  • ggsave() can write multi-page PDFs from a list of plots
  • theme_*(ink, paper, accent) arguments for foreground/background/highlight colors

How to Use This Skill

Reference File Structure

FilePurposeWhen to Read
quickstart.mdBasic ggplot pattern, ggsave, essential setupStarting out or quick reminder
geoms.mdAll major geoms with examplesChoosing chart types
scales.mdScales, axes, color palettes, labels, the scales packageAxis/color/label formatting
facets.mdfacet_wrap, facet_grid, labellers, spacingMulti-panel layouts
themes.mdBuilt-in themes, custom theme(), publication-ready stylingStyling and polish
extensions.mdpatchwork, ggrepel, ggridges, ggdistMulti-panel, labels, distributions
gotchas.md4.0 migration, common mistakes, factor ordering, save tipsDebugging or reviewing

Reading Order

  1. Quick plot? Start with quickstart.md
  2. Which geom? Check geoms.md
  3. Customize scales/axes? Read scales.md
  4. Multi-panel? Read facets.md
  5. Publication polish? Read themes.md
  6. Extensions? Read extensions.md
  7. Trouble? Check gotchas.md

Related Skills

SkillRelationship
plotninePython equivalent (plotnine ports ggplot2 to Python)
tidyverseData preparation -- tidy data feeds into ggplot2 pipelines
plotly-rInteractive R charts (use when interactivity needed)
gtPublication-quality tables (use for tabular output, not charts)
r-python-translationCross-language visualization translation
data-scientistMethod selection and visualization design guidance

Quick Decision Trees

"What chart type do I need?"

What are you visualizing?
├─ Relationship (x vs y)
│   ├─ Continuous x, continuous y → geom_point() + geom_smooth()
│   ├─ Time series → geom_line()
│   └─ With error/uncertainty → geom_pointrange() or geom_ribbon()
├─ Distribution
│   ├─ One variable → geom_histogram() or geom_density()
│   ├─ By group (few groups) → geom_boxplot() or geom_violin()
│   ├─ By group (many groups) → ggridges::geom_density_ridges()
│   └─ Full distribution detail → ggdist::stat_halfeye()
├─ Comparison
│   ├─ Counts → geom_bar()
│   ├─ Values → geom_col()
│   └─ Grouped → geom_col(position = "dodge")
├─ Composition
│   ├─ Parts of whole → geom_col(position = "fill")
│   └─ Over time → geom_area(position = "stack")
├─ Heatmap / tile → geom_tile() or geom_raster()
└─ Multiple plots → patchwork (p1 + p2) / p3

"How do I save this plot?"

Saving a plot?
├─ To PNG (default for DAAF) → ggsave("file.png", p, width = 10, height = 8, dpi = 300)
├─ To PDF → ggsave("file.pdf", p, width = 10, height = 8)
├─ To SVG → ggsave("file.svg", p, width = 10, height = 8)
├─ Multiple plots to one PDF → ggsave("file.pdf", list(p1, p2, p3))
└─ Temp file (smoke tests) → ggsave(tempfile(fileext = ".png"), p)

File-First Execution in Research Workflows

In DAAF research pipelines, all visualizations are generated through script files in scripts/stage8_analysis/, not interactively. This ensures auditability and reproducibility.

The pattern:

  1. Write plot code to scripts/stage8_analysis/{step}_{plot-name}.R
  2. Execute via bash {BASE_DIR}/scripts/run_with_capture.sh {script_path}
  3. Output gets appended to the script as comments
  4. Use ggsave() to save plots to the project output directory

See agent_reference/SCRIPT_EXECUTION_REFERENCE.md for the mandatory file-first execution protocol.

Quick Reference

Essential Setup

library(ggplot2)
library(scales)       # label_comma(), label_percent(), etc.
library(patchwork)    # plot composition: p1 + p2, p1 / p2
library(ggrepel)      # geom_text_repel(), geom_label_repel()
library(ggridges)     # geom_density_ridges()
library(ggdist)       # stat_halfeye(), stat_dots()

Basic Plot Pattern

p <- ggplot(df, aes(x = col_x, y = col_y)) +
  geom_point() +
  labs(title = "Title", x = "X Label", y = "Y Label") +
  theme_minimal()

ggsave("output.png", p, width = 10, height = 8, dpi = 300)

Common Geoms

GeomUse Case
geom_point()Scatter plots
geom_line()Line plots / time series
geom_bar()Count bars (stat = "count")
geom_col()Value bars (stat = "identity")
geom_histogram()Distributions
geom_density()Density curves
geom_boxplot()Box-and-whisker
geom_violin()Violin plots
geom_smooth()Trend lines
geom_tile()Heatmaps

Common Aesthetics

AestheticControlsUse size or linewidth?
x, yPositionN/A
colorPoint/line colorN/A
fillArea fill colorN/A
sizePoint size only (4.0+)size for points
linewidthLine width (4.0+)linewidth for lines
shapePoint shapeN/A
alphaTransparencyN/A
linetypeLine patternN/A

Topic Index

TopicReference File
Basic plot pattern./references/quickstart.md
ggsave() parameters./references/quickstart.md
Data requirements./references/quickstart.md
Scatter, line, bar, area./references/geoms.md
Histogram, density, boxplot./references/geoms.md
Smoothing, error bars./references/geoms.md
Heatmaps, tiles, text./references/geoms.md
Position adjustments./references/geoms.md
Continuous/discrete scales./references/scales.md
Color palettes (Brewer, viridis)./references/scales.md
Axis labels and formatting./references/scales.md
scales package helpers./references/scales.md
facet_wrap, facet_grid./references/facets.md
Free scales, labellers./references/facets.md
Built-in themes./references/themes.md
Custom theme() elements./references/themes.md
Publication-ready themes./references/themes.md
patchwork composition./references/extensions.md
ggrepel labels./references/extensions.md
ggridges ridgeline plots./references/extensions.md
ggdist distribution viz./references/extensions.md
linewidth vs size migration./references/gotchas.md
4.0 breaking changes./references/gotchas.md
Factor ordering./references/gotchas.md
Save resolution/dimensions./references/gotchas.md
Common errors./references/gotchas.md

Citation

When ggplot2 is used as a primary visualization tool, include in the report's Software & Tools references:

Wickham, H. (2016). ggplot2: Elegant Graphics for Data Analysis (2nd ed.). Springer-Verlag New York. https://ggplot2.tidyverse.org

Cite when: ggplot2 produces figures included in the report. Do not cite when: Only used for quick exploratory plots not included in deliverables.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Guide for creating DAAF agent definition files. Covers 12-section template, hook registration, skills-in-frontmatter, integration checklist. Use when adding or revising agents. For SKILL.md files, use skill-authoring instead.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DAAF-Contribution-Community/daaf2382026년 10월 17일 업데이트

Researcher-facing analytic triangulation ("creative verification") for stress-testing provisional findings and designing pre-specified challenges before an analysis runs. Turns a researcher's concern or focal claim into competing explanations, bounded discriminating tests, audited diagnostic artifacts, and evidence-calibrated interpretations in a hypothesis/evidence ledger — behavioral, output-level verification replacing line-by-line code review. Covers 12 challenge families organized by Shadish-Cook-Campbell validity type, named sensitivity statistics, pre-committed interpretation rules, anti-fishing guardrails, and interactive diagnostic-artifact QA. Use in Ad Hoc Collaboration to verify, challenge, or stress-test a result, or to design discriminating tests before an analysis runs. Not code-change verification (verify skill / code review) and not final adjudication or re-execution (data-verifier, Reproducibility Verification) — prospective, hypothesis-driven challenge design of analytic claims.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DAAF-Contribution-Community/daaf2382026년 10월 17일 업데이트

In-situ smoke testing that verifies a LIVE DAAF deployment functions end-to-end in whatever provider route it is configured for. Auto-detects the active install route (anthropic-subscription, openrouter, chatgpt-subscription shim, openai-api shim) and runs tiered probes: Tier 0 free preflight (route/env coherence, hooks, statuslines, shim health); Tier 1 one live round-trip (~cents); Tier 2 a six-probe functional battery (dispatch, coding, web, skill loading, isolation-strip, nested-dispatch deny); Tier D a zero-cost deterministic battery (bats, Pester, lint, safety-hook tests). Use after install, after a rebuild or update, after any provider/config change (new API key, model remap, shim change), for pre-release validation, or when asked "is my install working" or to "smoke test the deployment/config." Requires the DAAF_DEV=1 dev image; a contributor tool, not end-user-facing. NOT DAAFBench (model behavioral-adherence evaluation under benchmarks/) and NOT scripts/smoke_tests/ (R/Python library-package smoke tests).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DAAF-Contribution-Community/daaf2382026년 10월 17일 업데이트

Operational framework for the DAAF orchestrator. Defines engagement modes, confirmation protocol, subagent dispatch, context budget, and reference-loading. Loaded exclusively by the orchestrator — not for subagents or user questions.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DAAF-Contribution-Community/daaf2382026년 10월 17일 업데이트

Data science methodology and method-selection routing for quantitative research. Covers EDA, data validation, descriptive analysis, causal inference (IV, DiD, RD, synthetic control), clustering/PCA/UMAP, supervised ML, geospatial analysis, network analysis, and visualization design. Contains the canonical method-to-library routing tree, routed by execution language — Python: statsmodels (OLS/GLM/time series), pyfixest (FE/DiD), linearmodels (RE/GMM/SUR), svy (complex surveys), scikit-learn (clustering/prediction ML), geopandas (spatial), igraph (network analysis); R: r-stats (OLS/GLM/time series), fixest (FE/DiD), plm (panel/RE/IV), survey-r (complex surveys), tidymodels (ML), sf-terra (spatial), igraph-r (network analysis). Load the routed tool-specific skill before giving tool-specific advice or writing code — library skills encode environment constraints and curated caveats absent from general knowledge.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DAAF-Contribution-Community/daaf2382026년 10월 17일 업데이트

Interpretation guidance for Urban Institute Education Data Portal datasets. The Portal is a curation layer over federal data: lowercase variable names, integer-encoded categoricals, standardized missing codes (-1 missing, -2 not applicable, -3 suppressed). Covers year definitions, grade encoding (grade=-1 is Pre-K, not missing), suppression rates, ODC-By licensing, and cross-source join identifiers. Load before analyzing any Portal data. Routes to source-specific deep-dive skills for individual datasets.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DAAF-Contribution-Community/daaf2382026년 10월 17일 업데이트

DAAF-Contribution-Community의 스킬 모두 보기

이 스킬의 문제 신고