Learn R Programming

plotcli: Command-Line Plots for R

plotcli is an R package that brings the power of command-line plotting to your R environment. With a simple and intuitive interface, plotcli allows you to create and customize a variety of plot types directly in your console using Unicode Braille characters and ANSI colors.

Features

  • ggplotcli: Universal ggplot2 converter - render any ggplot in the terminal
  • 14 Supported Geoms: points, lines, bars, histograms, density, smooth, area, segments, and more
  • Faceting: Full support for facet_wrap() and facet_grid()
  • Theme Auto-Detection: Automatically respects ggplot2 themes (borders, grids)
  • Multiple Canvas Types: Braille (high-res), Block, or ASCII
  • Colored Output: Full ANSI color support for aesthetics
  • R6 Class Interface: Direct plotting with plotcli class

plotcli is heavily inspired by the excellent UnicodePlots.jl library.

Quick Start

library(plotcli)
library(ggplot2)

# Any ggplot2 plot works!
p <- ggplot(mtcars, aes(x = wt, y = mpg, color = factor(cyl))) +
  geom_point() +
  labs(title = "MPG vs Weight")

# Render in terminal
ggplotcli(p)

Output:

                    MPG vs Weight                     
  35.0 ⠤⠤⡧⠤⠤⠤⠤⠤⡧⠤⠤⠤⠤⠤⡧⠤⠤⠤⠤⠤⡧⠤⠤⠤⠤⠤⡧⠤⠤⠤⠤⠤⡧⠤⠤⠤⠤⠤⡧⠤⠤  
       ⠒⠒⣗⢒⠒⠒⠒⠒⡗⠒⠚⠒⠒⠒⡗⠒⠒⠒⠒⠒⡗⠒⠒⠒⠒⠒⡗⠒⠒⠒⠒⠒⡗⠒⠒⠒⠒⠒⡗⠒⠒  
  30.0 ⣉⣉⣏⣉⣉⣉⣉⣉⣏⣉⣉⣉⣉⣉⣏⣉⣉⣉⣉⣉⣏⣉⣉⣉⣉⣉⣏⣉⣉⣉⣉⣉⣏⣉⣉⣉⣉⣉⣏⣉⣉  
m      ⠤⠤⡧⠤⠤⠤⠤⠬⡧⠤⠤⠤⠤⠤⡧⠤⠤⠤⠤⠤⡧⠤⠤⠤⠤⠤⡧⠤⠤⠤⠤⠤⡧⠤⠤⠤⠤⠤⡧⠤⠤  
p 25.0 ⠒⠒⡗⠒⠒⠒⠒⠒⡗⠒⠒⠒⡒⠒⡗⠒⠒⠒⠒⠒⡗⠒⡚⠒⠒⠒⡗⠒⠒⠒⠒⠒⡗⠒⠒⠒⠒⠒⡗⠒⠒  
g 20.0 ⣉⣉⣏⣉⣉⣉⣉⣉⣏⣉⣉⣉⣉⣉⣏⣙⣉⣙⣙⣉⣏⣉⣙⣉⣉⣉⣏⣉⣉⣉⣉⣉⣏⣉⣉⣉⣉⣉⣏⣉⣉  
       ⠤⠤⡧⠤⠤⠤⠤⠤⡧⠤⠤⠤⠤⠤⡧⠤⠤⠤⠤⠤⡧⠤⠤⠤⠤⠼⡧⠤⠤⡤⠬⠤⡧⠤⠤⠤⠤⠤⡧⠤⠤  
  15.0 ⠒⠒⡗⠒⠒⠒⠒⠒⡗⠒⠒⠒⠒⠒⡗⠒⠒⠒⠒⠒⡗⠒⠒⠒⠒⠲⡷⡖⠒⠲⠒⠒⡗⠓⠒⠒⠒⠒⡗⠒⠒  
       ⣉⣉⣏⣉⣉⣉⣉⣉⣏⣉⣉⣉⣉⣉⣏⣉⣉⣉⣉⣉⣏⣉⣉⣉⣉⣉⣏⣉⣉⣉⣋⣉⣏⣉⣉⣉⣉⣉⣏⣉⣉  
  10.0 ⠤⠤⡧⠤⠤⠤⠤⠤⡧⠤⠤⠤⠤⠤⡧⠤⠤⠤⠤⠤⡧⠤⠤⠤⠤⠤⡧⠤⠤⠤⠤⠤⡧⠤⠤⠦⠤⠦⡧⠤⠤  
            2.0         3.0         4.0         5.0        
                             wt                            

Faceting Example

p <- ggplot(mtcars, aes(x = wt, y = mpg)) +
  geom_point(color = "blue") +
  facet_wrap(~cyl) +
  labs(title = "MPG by Cylinders") +
  theme_bw()  # Automatically adds borders!

ggplotcli(p, width = 70, height = 16)

Output:

                       MPG by Cylinders                        
               4                    6                    8     
      ⡏⠉⠩⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⢹ ⡏⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⢹ ⡏⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⢹
      ⡇   ⠁              ⢸ ⡇                  ⢸ ⡇                  ⢸
  30.0⡇⠉                 ⢸ ⡇                  ⢸ ⡇                  ⢸
      ⡇  ⢂               ⢸ ⡇                  ⢸ ⡇                  ⢸
      ⡇   ⠈⡀⢀ ⠈          ⢸ ⡇     ⡀⡀⢀          ⢸ ⡇                  ⢸
  20.0⡇                  ⢸ ⡇     ⠠  ⠠         ⢸ ⡇        ⢀ ⠠       ⢸
      ⡇                  ⢸ ⡇        ⠘         ⢸ ⡇          ⠄⢀      ⢸
      ⡇                  ⢸ ⡇                  ⢸ ⡇       ⠈⠐⡂⠂      ⠠⢸
  10.0⣇⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣸ ⣇⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣸ ⣇⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣒⣸
        2.0      4.0         2.0      4.0         2.0      4.0     

Styling Options

# With border and grid
ggplotcli(p, border = TRUE, grid = "major")

# Different canvas types
ggplotcli(p, canvas_type = "braille")  # High resolution (default)
ggplotcli(p, canvas_type = "block")    # Medium resolution  
ggplotcli(p, canvas_type = "ascii")    # Basic ASCII

Supported Geoms

GeomStatus
geom_point
geom_line, geom_path
geom_bar, geom_col, geom_histogram
geom_density
geom_smooth
geom_area
geom_segment, geom_hline, geom_vline
geom_rect
geom_text
geom_boxplot
geom_tile (heatmaps)Planned

Installation

# From CRAN
install.packages("plotcli")

# Or from GitHub for the latest development version
# Using remotes (recommended)
remotes::install_github("cheuerde/plotcli")

# Or using devtools
devtools::install_github("cheuerde/plotcli")

Direct R6 Class Usage

For more control, use the plotcli R6 class directly:

# Using plotcli R6 class directly
pc <- plotcli$new(width = 60, height = 20)
pc$add_data(mtcars$wt, mtcars$mpg)
pc$add_title("MPG vs Weight")
pc$print_plot()

Check the vignettes for all possible ways of using the package.

Showcase

Similar Projects

  • txtplot: The OG in R
  • r-plot: Collection of excellent terminal plotting functions
  • UnicodePlots.jl: The gold standard for terminal graphics
  • plotext: Powerful terminal graphics in python

License

plotcli is released under the LGPL-3 License.

Copy Link

Version

Install

install.packages('plotcli')

Monthly Downloads

187

Version

0.2.0

License

LGPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Claas Heuer

Last Published

November 27th, 2025

Functions in plotcli (0.2.0)

cbind_plots

Combine plot matrices horizontally
cbind.plotcli

Generic function for combining plotcli objects horizontally
extract_plot_labels

Extract Plot Labels from ggplot
color_to_term

Convert ggplot2 color to terminal color name
create_canvas

Create a canvas of the specified type
build_plot_output_v2

Build Plot Output with Axes and Title (v2)
extract_plot_style

Extract Plot Style from ggplot Theme
geom_text_handler

GeomText Handler
geom_density_handler

GeomDensity Handler
geom_boxplot_handler

GeomBoxplot Handler
geom_vline_handler

GeomVline Handler
create_scales

Create Scale Object from ggplot_build data
format_four_chars

Format number to four characters
geom_point_handler

GeomPoint Handler
geom_rect_handler

GeomRect Handler
create_panel_scales

Create Scales for a Single Panel
get_facet_info

Get Facet Information from Layout
draw_border

Draw Border Around Canvas
format_axis_label

Format Axis Label
.geom_registry

Geom Registry Environment
cat_plot_matrix

Print plot matrix
draw_grid

Draw Grid Lines on Canvas
geom_line_handler

GeomLine Handler
extract_legend_info

Extract Legend Information from ggplot
pclis

Short version of plotcli_scatter
pixel_to_braille

Convert pixel coordinates to Braille cell and dot position
get_data_subset

Get data subset for a specific geom
get_color_hue

Get the hue of a color (0-360 degrees)
geom_area_handler

GeomArea Handler
pclid

Short version of plotcli_density
get_geom_handler

Get a Geom Handler
pclibx

Short version of plotcli_box
geom_bar_handler

GeomBar/GeomCol Handler
ggplotcli

ggplotcli - Render ggplot2 objects in the terminal
get_term_colors

Get terminal colors
geom_path_handler

GeomPath Handler
is_braille

Check if a character is a Braille character
plotcli_line

Line plot using plotcli
init_color_mapping

Initialize color mapping for a set of ggplot colors
plotcli_histogram

Histogram plot using plotcli
geom_segment_handler

GeomSegment Handler
geom_smooth_handler

GeomSmooth Handler
plotcli_density

Density plot using plotcli
plotcli_box

Box plot using plotcli
geom_hline_handler

GeomHline Handler
geom_histogram_handler

GeomHistogram Handler
make_unique_names

Make unique names
make_colored

Make colored text
render_single_panel

Render a single panel (non-faceted) plot
plotcli_bar

Bar plot using plotcli
pclil

Short version of plotcli_line
plotcli

plotcli R6 Class
pclih

Short version of plotcli_histogram
is_geom_registered

Check if a Geom is Registered
+.plotcli

Overload the "+" operator for plotcli objects
rbind.plotcli

Generic function for combining plotcli objects vertically
render_faceted_plot

Render Faceted Plot
plotcli_scatter

Scatter plot using plotcli
remove_color_codes

Remove color codes from a string
plotcli_options

Set global options for plotcli
list_registered_geoms

List Registered Geoms
normalize_data

Normalize data
safe_aes_name

Safely extract aesthetic name from ggplot mapping
register_geom

Register a Geom Handler
pclib

Short version of plotcli_bar
rbind_plots

Combine plot matrices vertically
braille_dot_bit

Get Braille dot bit value
AsciiCanvas

ASCII Canvas Class
add_legend_to_output

Add Legend to Output Matrix
GeomRegistry

Geom Registry and Dispatch System
BlockCanvas

Block Canvas Class
braille_set_dot

Set a dot in a Braille character
BrailleCanvas

Braille Canvas Class
bresenham

Bresenham's line algorithm
Canvas

Canvas Classes for Terminal Plotting
build_plot_output

Build Plot Output with Axes and Title (legacy)