dot

packages and services management
Log | Files | Refs | README

commit db5bc456f0a79e89c9c84525e1a8700af5fcd0d4
parent bb796dd689a88eea8c7fc431097ef89253f59ee2
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Wed, 26 Jul 2017 08:47:43 +0200

bin/plot: with x and y axis

Diffstat:
Mbin/plot | 24++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/bin/plot b/bin/plot @@ -17,21 +17,33 @@ BEGIN { { maxx = split($0, dots) - maxy = 0 + maxy = max = 0 # scale the values and find the max for (x = 1; x <= maxx; x++) { + if (max < dots[x]) max = dots[x] dots[x] = int(dots[x] / stepy) if (maxy < dots[x]) maxy = dots[x] } # draw the grid - for (y = maxy; y >= 1; y -= 2) { - for (x = 1; x <= maxx; x++) { - printf (dots[x] >= y + 1 ? ":" : \ - dots[x] >= y ? "." : " ") - } + for (y = maxy + maxy % 2; y >= 1; y -= 2) { + if (y % 4) + printf "%" length(max) "s |", "" + else + printf "%" length(max) "d -|", (y - 1) * stepy + + for (x = 1; x <= maxx; x++) + printf "%s", (dots[x] >= y ? ":" : \ + dots[x] >= y - 1 ? "." : " ") + print "" } + + # draw 'x' axis + printf "%" length(max) "s0 +", "" + for (x = 1; x <= maxx; x++) + printf "-" + print "+ " maxx * stepx } ' "$@"