Skip to content

shandley/ggterm

Repository files navigation

ggterm logo

ggterm

npm version License: MIT

Create data visualizations by describing what you want. No syntax to memorize.

ggterm is a Grammar of Graphics toolkit for Claude Code. Describe your data and what you want to see in natural language — ggterm handles scales, legends, colors, and layout automatically. Plots appear instantly in a live browser panel alongside your terminal.

ggterm live viewer in Wave terminal

Quick Start

mkdir my-analysis && cd my-analysis
npx ggterm-plot setup

That's it. This installs everything, generates a welcome plot, opens the live viewer in your browser, and starts the server. Now talk to Claude:

You: Load the iris dataset and show me sepal length vs petal length, colored by species

Claude: [Creates scatter plot — appears instantly in the live viewer]

You: Add a trend line and style it like Nature journal

Claude: [Updates the plot in place with regression line and Nature styling]

You: Export as PNG for my paper

Claude: [Generates publication-ready output]

What You Can Do

You say... What happens
"Load my data and show me X vs Y" Scatter plot with automatic scales and labels
"Color by group" Color encoding with legend
"Show the distribution of X" Histogram or density plot
"Compare groups with box plots" Grouped boxplots with stats
"Add a trend line" Linear or loess regression overlay
"Style like Tufte / Economist / Nature" Publication style presets
"Export as PNG" Publication-ready output
"Show me my previous plots" Browse plot history

66 Plot Types

ggterm includes specialized visualizations across domains:

Category Types
Essentials scatter, line, bar, area, histogram, density, boxplot, violin
Advanced ridgeline, beeswarm, heatmap, treemap, sankey, calendar heatmap, lollipop, waffle
Scientific volcano plot, Manhattan plot, Kaplan-Meier curves, forest plot, ROC curve, Q-Q plot, Bland-Altman, PCA biplot
Diagnostics ECDF, funnel plot, control chart, scree plot, correlation matrix, UpSet plot, dendrogram
Terminal-Native sparkline, braille (8x resolution), bullet chart, waffle chart

See the full Geometry Reference.

Built-in Datasets

Start exploring immediately with bundled datasets — no files needed:

You: Plot the iris dataset, sepal length vs petal length, colored by species

You: Create a volcano plot of the airway DESeq2 results

You: Show Kaplan-Meier survival curves for the lung data, stratified by sex
Dataset Rows Columns
iris 150 sepal_length, sepal_width, petal_length, petal_width, species
mtcars 16 mpg, cyl, hp, wt, name
airway 500 gene, baseMean, log2FoldChange, lfcSE, pvalue, padj
lung 227 time, status, age, sex, ph_ecog

airway: DESeq2 differential expression results from Himes et al. 2014 (human airway smooth muscle cells). lung: NCCTG lung cancer survival data (Loprinzi et al. 1994).

Or bring your own CSV, JSON, or JSONL files.

How It Works

ggterm runs as a companion to Claude Code. The live viewer sits in a browser panel (or Wave terminal side panel) and automatically displays every plot you create:

  • Instant display — plots appear as interactive Vega-Lite visualizations (tooltips, zoom, pan)
  • Command palette — press Cmd+K to fuzzy-search 80+ commands, all 66 geom types, style presets, and export actions
  • Plot history — every plot saved automatically; press h for the history sidebar, arrow keys to browse, Home/End to jump
  • Help panel — press ? for a 5-tab reference (Getting Started, Plot Types, Shortcuts, Styles, Export)
  • Data inventory — on setup, ggterm scans your directory for CSV, TSV, JSON, and JSONL files, analyzes column types and ranges, and writes a catalog so Claude already knows your data before you ask
  • Style in place — apply publication presets (Wilke, Tufte, Nature, Economist, APA) without re-running; viewer updates live
  • Export — press s/p for SVG/PNG directly from the viewer, or generate standalone HTML

Under the hood, ggterm is a comprehensive Grammar of Graphics implementation — the same foundation as R's ggplot2. Every plot is represented as a declarative PlotSpec that can be rendered to terminal ASCII art or converted to Vega-Lite for the browser. 66 geometry types, 75 scales, statistical transforms, faceting, and themes — all composable through the grammar.

Examples

See complete AI-driven workflows with real data:

Example What you'll learn
Exploratory Analysis Discover patterns in the mtcars dataset through conversation
Publication Figures Iteratively refine iris plots to publication quality
Streaming Dashboard Build a real-time monitoring display
Comparative Analysis Compare distributions with statistical annotations
Scientific Visualizations Volcano, Manhattan, Kaplan-Meier, forest, ROC plots

Installation Options

One Command (Recommended)

mkdir my-analysis && cd my-analysis
npx ggterm-plot setup    # Init + welcome plot + open browser + start server

Add to Existing Project

npm install @ggterm/core
npx ggterm-plot init     # Install Claude Code skills
npx ggterm-plot serve    # Start live viewer

Interactive REPL (No AI)

npx ggterm
ggterm> .data iris
Loaded Iris dataset: 150 rows, 5 columns

ggterm> gg(data).aes({x: "sepal_length", y: "petal_length", color: "species"}).geom(geom_point())

              Sepal vs Petal Length
  7.0 ┤                         ■■■■
      │                      ■■■■■■■■
  6.0 ┤                   ■■■■■■■■
      │               ●●●●●■■■■■
  5.0 ┤            ●●●●●●●●●
      │         ●●●●●●●●
  4.0 ┤       ●●●●●●
      │     ●●●●
  3.0 ┤   ●●●
      │
  2.0 ┤▲▲▲▲▲▲
      │▲▲▲▲▲▲▲
  1.0 ┤▲▲▲▲
      └──────────────────────────────────
       4.5   5.0   5.5   6.0   6.5   7.0

      ▲ setosa  ● versicolor  ■ virginica

For Developers

Use the programmatic API directly:

import { gg, geom_point, scale_color_viridis } from '@ggterm/core'

const plot = gg(data)
  .aes({ x: 'sepal_length', y: 'petal_length', color: 'species' })
  .geom(geom_point())
  .scale(scale_color_viridis())
  .labs({ title: 'Iris Dataset' })

console.log(plot.render({ width: 80, height: 24 }))

Every plot is a backend-agnostic PlotSpec — a JSON-serializable specification consumed by the terminal renderer or Vega-Lite exporter. New backends can be added without modifying the grammar layer. See the Architecture for details.

Resources

License

MIT

About

Grammar of Graphics primitive catalog: 65 geoms, 73 scales, terminal and Vega-Lite backends, Claude Code AI integration

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors