An interactive shell for exploring data and building plots with the grammar of graphics.
Tip: The REPL provides a direct terminal interface to ggterm's grammar engine. For the full interactive experience with Vega-Lite visualization in the browser, use
npx ggterm-plot setupand talk to Claude Code instead. See the Quick Start Guide.
# Start the interactive REPL
npx ggterm
# Or with options
npx ggterm --width 100 --height 30| Option | Description |
|---|---|
-h, --help |
Show help message |
-v, --version |
Show version |
-e, --execute <code> |
Execute code and exit |
-w, --width <n> |
Set plot width (default: 70) |
-H, --height <n> |
Set plot height (default: 20) |
--no-colors |
Disable colors |
Commands start with a dot (.):
.data Show current data summary
.data clear Clear current data
.data sample <n> Generate n sample rows
.data iris Load Iris dataset
.data mtcars Load mtcars dataset
.load <file.json> Load data from JSON file
.plot Render current plot
.size <width> <height> Set plot dimensions
.theme <name> Set theme (default, minimal, dark)
.save <filename> Save plot to file
.help Show help
.help <topic> Show topic help (geoms, scales, aes)
.examples Show example code
.history Show command history
.vars Show defined variables
.clear Clear screen
.reset Reset state
.quit Exit REPL
The REPL provides all ggterm functions in scope. Build plots using the grammar of graphics:
// Load sample data
.data sample 50
// Create a scatter plot
p = gg(data).aes({x: "x", y: "y"}).geom(geom_point())
// Add color by group
p = gg(data).aes({x: "x", y: "y", color: "group"}).geom(geom_point())
// Add labels
p = gg(data)
.aes({x: "x", y: "y"})
.geom(geom_point())
.labs({title: "My Plot", x: "X Axis", y: "Y Axis"})| Function | Description |
|---|---|
geom_point() |
Scatter plot |
geom_line() |
Line chart |
geom_bar() |
Bar chart |
geom_histogram() |
Histogram |
geom_boxplot() |
Box plot |
geom_area() |
Area chart |
geom_tile() |
Heatmap tiles |
geom_errorbar() |
Error bars |
geom_hline() |
Horizontal line |
geom_vline() |
Vertical line |
geom_text() |
Text labels |
| Function | Description |
|---|---|
scale_x_continuous() |
Continuous X axis |
scale_y_continuous() |
Continuous Y axis |
scale_x_log10() |
Log scale X |
scale_y_log10() |
Log scale Y |
scale_color_viridis() |
Viridis color palette |
scale_color_discrete() |
Discrete colors |
scale_fill_viridis() |
Viridis fill palette |
| Function | Description |
|---|---|
facet_wrap("var") |
Wrap by variable |
facet_grid({rows, cols}) |
Grid faceting |
| Function | Description |
|---|---|
defaultTheme() |
Default theme |
themeMinimal() |
Minimal theme |
themeDark() |
Dark theme |
The REPL includes helper functions for generating data:
// Range of integers
range(0, 10) // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
// Random numbers
random(5) // [0.23, 0.87, 0.12, 0.95, 0.44]
// Sequence with step
seq(0, 10, 2) // [0, 2, 4, 6, 8, 10]
// Normal distribution
rnorm(100, 0, 1) // 100 samples from N(0,1)Classic iris flower dataset with sepal/petal measurements:
.data iris
Columns: sepal_length, sepal_width, petal_length, petal_width, species
gg(data)
.aes({x: "sepal_length", y: "petal_length", color: "species"})
.geom(geom_point())Car performance data:
.data mtcars
Columns: name, mpg, cyl, hp, wt
gg(data)
.aes({x: "wt", y: "mpg", color: "cyl"})
.geom(geom_point())
.labs({title: "Fuel Efficiency", x: "Weight", y: "MPG"}).data sample 30
gg(data).aes({x: "x", y: "y"}).geom(geom_point()).data sample 20
gg(data)
.aes({x: "x", y: "y"})
.geom(geom_line())
.geom(geom_point()).data sample 50
gg(data)
.aes({x: "x", y: "y", color: "group"})
.geom(geom_point())
.scale(scale_color_viridis())// Generate random data
data = rnorm(100, 50, 10).map(v => ({value: v}))
gg(data).aes({x: "value"}).geom(geom_histogram({bins: 20}))data = [{cat: "A", val: 30}, {cat: "B", val: 45}, {cat: "C", val: 25}]
gg(data).aes({x: "cat", y: "val"}).geom(geom_bar({stat: "identity"})).data iris
gg(data)
.aes({x: "sepal_length", y: "petal_length", color: "species"})
.geom(geom_point())
.theme(themeDark()).data sample 50
gg(data).aes({x: "x", y: "y"}).geom(geom_point())
.save myplot.txtExecute code directly without entering the REPL:
# Quick scatter plot
npx ggterm -e ".data sample 30; gg(data).aes({x:'x',y:'y'}).geom(geom_point())"
# Custom dimensions
npx ggterm -w 100 -H 30 -e ".data iris; gg(data).aes({x:'sepal_length',y:'petal_length',color:'species'}).geom(geom_point())"| Key | Action |
|---|---|
Tab |
Auto-complete commands and functions |
Up/Down |
Navigate command history |
Ctrl+C |
Cancel current input |
Ctrl+D |
Exit REPL |
-
Auto-render: By default, plots render automatically when you create them. The last plot is stored and can be re-rendered with
.plot. -
Variables: Assign plots to variables for later modification:
p = gg(data).aes({x: "x", y: "y"}).geom(geom_point()) p.labs({title: "Updated Title"})
-
Data exploration: Use
.datato see a summary of your current data including column names. -
Theme switching: Apply themes to existing plots:
.theme dark
-
Resize plots: Adjust dimensions on the fly:
.size 100 30 .plot