#data #vega-lite #visualization #cli-tool #vega

bin+lib vl

A CLI tool to generate Vega-Lite specifications

3 releases

0.0.3 May 9, 2022
0.0.2 May 6, 2022
0.0.1 May 2, 2022

#12 in #vega

BSD-3-Clause

175KB
324 lines

VL

A CLI to generate Vega-Lite specifications.

This project is currently a major work in progress so many parts are unrefined or may not work.

The overall goal of this tool is to be useful in quick shell scripts for visualizing data. For anything more involved or long term, consider any of the more mature Vega-Lite bindings.

Usage

A spec can either be fed data directly with a file:

vl 'data/cars.json' bar --x='f:Origin' --y='f:Miles_per_Gallon,t:q'

Or it can be piped in:

cat data/cars.json | vl bar --x='f:Origin' --y='f:Miles_per_Gallon,t:q'

Alternatively one can choose to not feed in data at all and just generate the encoding and mark type:

vl bar --x='f:Origin' --y='f:Miles_per_Gallon,t:q'

There is a comma-separated short hand for encodings to allow for quick plotting (of the format key:value):

key value
a or aggregate string
b or bin bool
f or field string
t or type string*
u or timeUnit string

alternatively any key:value pair should just be passed through as well.

*For type there are also the following shorthands:

char type
q quantitative
t temporal
o ordinal
n nominal
g geojson

Config

vl can make use of a config file located at ~/.config/vl/config.json. The config file takes any values that Vega-Lite's config parameter takes.

If you would like to ignore your config file for a specific plot, you can plot with:

vl --bare [...]


This tool is particularly useful with a terminal that allows inline graphics such as Kitty along with the Vega-Lite CLI. With the above, one can run:

cat data/cars.json | vl bar --x='f:Origin' --y='f:Miles_per_Gallon,t:q' | vl2png | icat

where icat is replaced by whatever your terminal's graphic representation command is.

Dependencies

~2.1–3.5MB
~61K SLoC