diff options
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 271 |
1 files changed, 171 insertions, 100 deletions
@@ -14,9 +14,10 @@ Dead simple terminal plots from JSON data. Bar charts and line charts are suppor - [Y values only (X=index)](#y-values-only-xindex) - [Array data](#array-data) - [Line chart](#line-chart) - - [Y values only (X=index)](#y-values-only-xindex-1) - [Array data, separate X and Y values](#array-data-separate-x-and-y-values) - [Array data, XY pairs](#array-data-xy-pairs) + - [Y values only (X=index)](#y-values-only-xindex-1) + - [Scatter plot](#scatter-plot) <!-- /TOC --> @@ -30,16 +31,16 @@ Or [download the binary](https://github.com/sgreben/jp/releases/latest) from the ```bash # Linux -curl -LO https://github.com/sgreben/jp/releases/download/1.0.1/jp_1.0.1_linux_x86_64.zip -unzip jp_1.0.1_linux_x86_64.zip +curl -LO https://github.com/sgreben/jp/releases/download/1.1.0/jp_1.1.0_linux_x86_64.zip +unzip jp_1.1.0_linux_x86_64.zip # OS X -curl -LO https://github.com/sgreben/jp/releases/download/1.0.1/jp_1.0.1_osx_x86_64.zip -unzip jp_1.0.1_osx_x86_64.zip +curl -LO https://github.com/sgreben/jp/releases/download/1.1.0/jp_1.1.0_osx_x86_64.zip +unzip jp_1.1.0_osx_x86_64.zip # Windows -curl -LO https://github.com/sgreben/jp/releases/download/1.0.1/jp_1.0.1_windows_x86_64.zip -unzip jp_1.0.1_windows_x86_64.zip +curl -LO https://github.com/sgreben/jp/releases/download/1.1.0/jp_1.1.0_windows_x86_64.zip +unzip jp_1.1.0_windows_x86_64.zip ``` ## Use it @@ -49,7 +50,7 @@ unzip jp_1.0.1_windows_x86_64.zip ```text Usage of jp: -type value - Plot type. One of [line bar] (default line) + Plot type. One of [line bar scatter] (default line) -x string x values (JSONPath expression) -y string @@ -60,6 +61,8 @@ Usage of jp: Plot height (default 0 (auto)) -width int Plot width (default 0 (auto)) + -canvas value + Canvas type. One of [full quarter braille auto] (default auto) ``` ## Examples @@ -68,6 +71,7 @@ Usage of jp: In case you're on mobile, here's some PNGs of what `jp` output looks like: +- ![Scatter plot](docs/scatter_plot.png) - ![Bar chart](docs/bar_chart.png) - ![Line chart](docs/line_chart.png) @@ -77,16 +81,18 @@ In case you're on mobile, here's some PNGs of what `jp` output looks like: ```bash $ cat examples/tcp-time.json | jp -x ..Label -y ..Count -type bar - 69.0 - █████████████ - █████████████ - █████████████ - █████████████ - █████████████ 21.0 - █████████████ █████████████ 7.0 2.0 1.0 - █████████████ █████████████ ▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁ - - 46.85267ms 48.38578ms 49.91889ms 51.452ms 52.98511ms + + 69 + █████████████ + █████████████ + █████████████ + █████████████ + █████████████ + █████████████ 21 + █████████████ █████████████ 7 2 1 + █████████████ █████████████ ▄▄▄▄▄▄▄▄▄▄▄▄▄ ▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁ + + 46.85267ms 48.38578ms 49.91889ms 51.452ms 52.98511ms ``` @@ -94,16 +100,18 @@ $ cat examples/tcp-time.json | jp -x ..Label -y ..Count -type bar ```bash $ cat examples/tcp-time.json | jp -xy "..[Label,Count]" -type bar - 69.0 - █████████████ - █████████████ - █████████████ - █████████████ - █████████████ 21.0 - █████████████ █████████████ 7.0 2.0 1.0 - █████████████ █████████████ ▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁ - - 46.85267ms 48.38578ms 49.91889ms 51.452ms 52.98511ms + + 69 + █████████████ + █████████████ + █████████████ + █████████████ + █████████████ + █████████████ 21 + █████████████ █████████████ 7 2 1 + █████████████ █████████████ ▄▄▄▄▄▄▄▄▄▄▄▄▄ ▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁ + + 46.85267ms 48.38578ms 49.91889ms 51.452ms 52.98511ms ``` #### Y values only (X=index) @@ -111,16 +119,17 @@ $ cat examples/tcp-time.json | jp -xy "..[Label,Count]" -type bar ```bash $ cat examples/tcp-time.json | jp -y ..Count -type bar - 69.0 - █████████████ - █████████████ - █████████████ - █████████████ - █████████████ 21.0 - █████████████ █████████████ 7.0 2.0 1.0 - █████████████ █████████████ ▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁ - - 0 1 2 3 4 + 69 + █████████████ + █████████████ + █████████████ + █████████████ + █████████████ + █████████████ 21 + █████████████ █████████████ 7 2 1 + █████████████ █████████████ ▄▄▄▄▄▄▄▄▄▄▄▄▄ ▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁ + + 0 1 2 3 4 ``` #### Array data @@ -128,83 +137,145 @@ $ cat examples/tcp-time.json | jp -y ..Count -type bar ```bash $ echo '[[-3, 5], [-2, 0], [-1, 0.1], [0, 1], [1, 2], [2, 3]]' | jp -xy '[*][0, 1]' -type bar - 5.0 - ███████████ - ███████████ - ███████████ 3.0 - ███████████ ███████████ - ███████████ 2.0 ███████████ - ███████████ 0.0 0.1 1.0 ███████████ ███████████ - ███████████ ▁▁▁▁▁▁▁▁▁▁▁ ███████████ ███████████ ███████████ - - -3 -2 -1 0 1 2 + 5 + ███████████ + ███████████ + ███████████ 3 + ███████████ ▄▄▄▄▄▄▄▄▄▄▄ + ███████████ 2 ███████████ + ███████████ 1 ███████████ ███████████ + ███████████ 0.1 ▄▄▄▄▄▄▄▄▄▄▄ ███████████ ███████████ + ███████████ 0 ▁▁▁▁▁▁▁▁▁▁▁ ███████████ ███████████ ███████████ + + -3 -2 -1 0 1 2 ``` ### Line chart -#### Y values only (X=index) +#### Array data, separate X and Y values ```bash -$ cat examples/tcp-time.json | jp -y ..Duration - -59970040.9│ - │ - │ - │ █ - │██ - │██ █ - │█ █ █ █ - y█ █ ██ ██ █ █ ███ ███ █ █ █ - │ ██ ██ ███ ████ ███ ██ █ ██ █ ███ █ ██ █ █ ██ ██ ██ ██ █ ██ █ █ █ █ - │ █ █ ██ █ ██ ████ ██ █████ ██████ █ ██ ████████ █ ██ █ - │ - │ - │ -42167403.0└───────────────────────────────────────x───────────────────────────────────────────────── - 0.0 99.0 +$ jq -n '[range(200)/20 | [., sin]]' | jp -x '[*][0]' -y '[*][1]' + 1.059955│ ▄▄▄▄▖ ▄▄▄▄▖ + │ ▗▀ ▝▚▖ ▗▛▘ ▝▚▖ + │ ▟▘ ▀▖ ▄▘ ▝▖ + │ ▟ ▝▖ ▞▘ ▝▖ + │ ▟ ▝▖ ▞▘ ▝▖ + │ ▐ ▐ ▗▘ ▐▖ + │ ▐▘ ▚ ▗▘ ▐ + │▗▘ ▚ ▞ ▚ + │▞ ▝▖ ▞ ▌ + │ ▝▖ ▐ ▝▖ + │ ▐ ▗▘ ▀▖ + │ ▚ ▗▘ ▚ + │ ▚ ▗▞ ▙ + │ ▝▚ ▞ ▘ + │ ▝▄ ▗▞ + │ ▝▙ ▞ + │ ▚▖ ▄▛ + │ ▝▀▀▀▀▘ + -1.059955└───────────────────────────────────────────────────────────────────── + 0 10.547 ``` -#### Array data, separate X and Y values +#### Array data, XY pairs ```bash -$ jq -n '[range(200)/20 | [., sin]]' | jp -x '[*][0]' -y '[*][1]' +$ jq -n '[range(200)/20 | [., sin]]' | jp -xy '[*][0, 1]' -1.1 │ ███████ ██████ - │ ███ ███ ███ ███ - │ ███ ██ ██ ███ - │ ██ ███ ██ ██ - │ █ ██ ██ ███ - │██ ██ ██ ██ - │█ █ ██ ██ - y █ ██ █ - │ ██ ██ ██ - │ ██ ██ ██ - │ ██ ██ - │ ██ ████ - │ ██████ --1.1└───────────────────────────────────x─────────────────────────────────────── - 0.0 9.9 + 1.059955│ ▄▄▄▄▖ ▄▄▄▄▖ + │ ▗▀ ▝▚▖ ▗▛▘ ▝▚▖ + │ ▟▘ ▀▖ ▄▘ ▝▖ + │ ▟ ▝▖ ▞▘ ▝▖ + │ ▟ ▝▖ ▞▘ ▝▖ + │ ▐ ▐ ▗▘ ▐▖ + │ ▐▘ ▚ ▗▘ ▐ + │▗▘ ▚ ▞ ▚ + │▞ ▝▖ ▞ ▌ + │ ▝▖ ▐ ▝▖ + │ ▐ ▗▘ ▀▖ + │ ▚ ▗▘ ▚ + │ ▚ ▗▞ ▙ + │ ▝▚ ▞ ▘ + │ ▝▄ ▗▞ + │ ▝▙ ▞ + │ ▚▖ ▄▛ + │ ▝▀▀▀▀▘ + -1.059955└───────────────────────────────────────────────────────────────────── + 0 10.547 ``` -#### Array data, XY pairs +#### Y values only (X=index) ```bash -$ jq -n '[range(200)/20 | [., sin]]' | jp -xy '[*][0, 1]' +$ cat examples/tcp-time.json | jp -y ..Duration -1.1 │ ███████ ██████ - │ ███ ███ ███ ███ - │ ███ ██ ██ ███ - │ ██ ███ ██ ██ - │ █ ██ ██ ███ - │██ ██ ██ ██ - │█ █ ██ ██ - y █ ██ █ - │ ██ ██ ██ - │ ██ ██ ██ - │ ██ ██ - │ ██ ████ - │ ██████ --1.1└───────────────────────────────────x─────────────────────────────────────── - 0.0 9.9 + 5.342888e+07│▐▌ + │▐▌ + │▐▐ + │▐▐ ▐ + │▐▐ ▐ + │▐▐ ▐ + │▐▐ ▐ + │▞▐ ▐▖ + │▌▐ ▐▌ + │▌▐ ▐▌ + │▌▐ ▞▌ ▌ + │▌▐ ▗ ▄ ▌▌ ▌ + │▘▐ ▗ ▐ ▞▐ ▌▌ ▌ + │ ▐ ▗ ▟ █ ▌▐ ▌▌ ▗▌ + │ ▐ ▙ ▐▌ █ █ ▌▐ ▟ ▌▌ ▐▌ + │ ▌ ▛▖ ▐▐ ▗▜ █ ▌ ▌▗ █ ▌▌ ▐▌ + │ ▌ ▟ ▚ ▌▐▗ ▐▝▟▐ ▌ ▌▟▐ ▌ ▌▚ ▐▌ ▖ + │ ▌ █ ▐ ▌▐▐▌▐ █ ▌▗ ▐ ▌▛▟ ▌▗ ▌▐ ▐▐ ▌ + │ ▌▗▀ ▝▄▘ ▛▐▌ ▛ ▌▟ ▐ ▀ ▌ ▌▐ ▌▐ ▐▐ ▗▚ + │ ▌▐ ▘ ▌ ▘ ▌ ▌█ ▐ ▘ ▐▛▖▌▐ ▐▐ ▗▌ ▖ ▖ ▐▐ + │ ▙▐ ▘ ▘ █▐ ▐ ▝▌▌▌▐▄ ▞▐ ▌▌▗▜ ▐▌ ▐▐ ▗▖ + │ ▜▐ ▌ ▌▟ █ ▌▌▐ ▄▘▚▐▐ ▗▄ ▌▐▖ ▗ ▞▐▐ ▞▚ ▗ ▖▗▌▐▄ + │ ▝▞ ▙▘ ▜ ▐▌▐▐▜ ▐▞ ▌▐▝▟ ▝▄▀▄▘▝▞▀▘▝▖ ▞▄▌▌▌▌ + │ ▌ ▛ ▐ ▌▐▌▝ ▝▌ ▚▌ ▌ ▚▞▘▜▐ ▐▘ + │ ▘ ▘ ▝ ▝▌ ▘ ▝ ▝ + │ + │ + │ + 4.591664e+07└────────────────────────────────────────────────────────────────── + 0 97.02 ``` + +### Scatter plot + +```bash +$ cat examples/mvrnorm.json | jp -xy '..[x,y]' -type scatter + + 3.535344│ ⠄ ⠄ + │ ⠈⠂ ⠂ ⡀ ⠂ + │ ⠐⡀⡀⡂ ⠁ ⢄ ⠁ ⠠ + │ ⡀ ⠆ ⠈ ⠄⡀ ⠂ + │ ⡀ ⠠ ⡀ ⡀ ⠄ ⡀⠐⠄⠁⠐ ⠠⢆⠠⠂⠂⠄⣀⢈ ⡀⠈ ⡀ + │ ⡀⠂⠂⠄ ⡀⠂⢔⠠ ⢤⢀⠌⣡⠁⠦⠄⠐⡐⠂⣀⠅⠁⠈ ⠂ ⠈⠁⠁ ⡀ ⠄ + │ ⡀ ⢀ ⠄ ⠈⠠ ⠡⠑⠈⠈⢢⡁⡄⢈⠂⢡⠈⡄⡀⠈⠰⢉⡠⠘⢄⢃⠉⢀⣄⠢⠠⠄ ⠠ ⡀⠁ ⡀ ⠂ + │ ⠈ ⡂⠈⡁⠈⠄⢂⡹⡐⡡⡆⡥⣙⡶⡼⠱⣅⣅⣼⢗⡱⢐⣈⠑⢁⠂ ⢐⢁⠭⠘⡀ ⠈ + │ ⠁ ⢀⠄⢈⠈⡰⢀⡥⠋⣧⣓⣚⡛⢲⣽⣝⣭⢙⣟⢲⡽⣋⡠⣿⣜⣵⠙⡦⠗ ⣡⠁⠁⠁⠄⠠ ⠄⡂ + │ ⠄⠌⠌⠡⠉⡐⢯⣵⡏⢵⡞⠂⢰⣽⣷⢛⣯⡣⣷⢭⣞⣏⠤⣾⢡⡻⠢⢊⢠⡠⠸⢄⣃⡀⢁⠐ ⠐⡀ ⠂ ⠄ + │ ⠨ ⡈⠂ ⢀⢑⠄⣜⡾⣴⢨⠶⣪⣧⢿⣷⣷⡱⣿⣞⣲⣮⣮⣯⢾⡷⡬⡷⣺⠤⢏⡼⣨⢌⡬⠠⢂⢠⠒⠱⠆⡈ + │ ⠈ ⠃ ⠄⡐⠂⠐⢀⢈⣂⡈⣳⣷⣜⢺⣿⣹⣷⣼⣯⡿⣃⣽⣿⢾⣟⣾⢵⣻⠯⡼⡃⣼⣗⢲⠪⠇⣉⠺ ⢱⠠⠙⡀⢐⠌ + │ ⠄ ⠈⠊⠐⠑⠨⠚⢁⡊⢾⡶⢩⢿⣏⣽⢞⣼⣇⣵⣿⣿⣽⣿⢽⣭⠺⣿⣽⣳⢚⣾⣻⣾⣜⠩⡒⣃⠈⢢⠕⢂⢰⡀ ⡔⢀⢀ ⡀ + │ ⢀⠂⠁⠂⠇ ⠂⠊⢀⠐⡘⡍⡇⣚⢸⢟⣯⢿⣳⡪⣫⣵⣿⣯⣿⢿⣷⣻⣖⣗⣻⣚⢥⡷⣕⣏⠶⠊⠄⣠⠰⠂⡄⠂ ⠄⠁ + │ ⠠⢂ ⠘⠐⣀ ⣀⢡⢐⠔⢫⠯⢕⠫⠿⣹⢶⣾⡻⣭⣽⢗⠿⣹⣛⣺⣿⠯⢲⡼⣵⢉⣭⢐⣟⡍⠄⠈⠥⠄ ⠁ ⠄ + │ ⠈⠂ ⠊⡀⡈⠢⡌⡠⠖⢤⠥⡑⣯⣾⣴⣯⡿⣯⣝⣯⣿⠧⣽⣒⢾⣼⣻⣛⣗⡹⡽⢪⠯⠒⡨⠈ ⠈⡐⢄ ⠂⠘⠠ ⠂ + │ ⠰ ⡀⠃⠁⠠ ⠉⡈⡨⡱⢍⠌⠷⣯⠫⠬⡙⣴⣯⡣⡟⡮⠩⣫⠿⢞⢵⡰⠞⡂⠴ ⠕⢀⡂⠁ ⢀ ⠤ ⠈ + │ ⢩⠂ ⠁⡄ ⢀⠲⢂⠑⢁⡘⠄⠵⣣⢑⢻⠨⡩⣌⠕⢮⣮⣋⢹⡁⣊⡃⠈⡕⡘⡠⠨⠄⡘⠨ ⠊⠁ ⠂ + │ ⠐ ⢀ ⠈⠐⠔⠈ ⠁⢀⣀⡃⣊⢁⡘⠁⠛⠨ ⠒⡑⡀⠵⢙⠄⠡⠢⠃⠄⠋⠅ ⠥⠁⠠⢀ ⠄ + │ ⢀⢁ ⠆ ⠉⠁⠐ ⠄⠁⢑⡀⢀⠠⠑⢡⢊⠂⠑⠌⡅⠊⠄⠉⢈⡐ ⡀ ⠠ ⠂ + │ ⢀ ⠑ ⠂ ⡁ ⠌⢠⠈⠂⠄⠉⡃⠈⠄ ⠂⠠⠁ ⠄ ⢀ ⠠ + │ ⠐ ⠐ ⢁⠂⠂⠢⠠⠄⠔⠐ ⠁ + │ ⠢ ⠁ ⠂⠐ ⠐ ⠐ ⠈ + │ ⢀ ⠄⠈ ⠈ + │ ⠐ + │ + │ + │ ⠈ +-4.271874└───────────────────────────────────────────────────────────────────── + -4.08815 3.79083 +```
\ No newline at end of file |