MyNixOS website logo
Description

Command Line Interface Plotting.

The 'plotcli' package provides terminal-based plotting in R. It supports colored scatter plots, line plots, bar plots, boxplots, histograms, density plots, and more. The 'ggplotcli()' function is a universal converter that renders any 'ggplot2' plot in the terminal using Unicode Braille characters or ASCII. Features include support for 15+ geom types, faceting (facet_wrap/facet_grid), automatic theme detection, legends, optimized color mapping, and multiple canvas types.

plotcli: Command-Line Plots for R

CRAN status CRAN checks Downloads Downloads

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.

Metadata

Version

0.2.0

License

Unknown

Platforms (78)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows