Outstanding wishlist.
" (range expected)\n"
);
},
+ 'log|e!',
'header!',
'markers|m=s',
'graph-format=s' => sub {
) // 0;
my $minval = $opt{minval} // min $order[-1] // (), 0;
my $range = $maxval - $minval;
+$range &&= log $maxval if $opt{log};
my $lenval = $opt{'value-length'} // max map { length } @order;
my $len = defined $opt{trim} && $opt{trim} <= 0 ? -$opt{trim} + 1 :
max map { length $values[$_] && length $lines[$_] }
next;
};
$pos -= $minval;
+ $pos &&= log $pos if $opt{log};
$pos >= 0 or next;
color(36) for $barmark[$pos * $size] = $char;
}
next;
}
printf '%-*s', $len + length($val), $line;
+ my $barlen = $values[$nr] || 0;
+ $barlen &&= log $barlen if $opt{log};
print $barmark[$_] // $opt{'graph-format'}
- for 1 .. $size && (($values[$nr] || 0) - $minval) * $size + .5;
+ for 1 .. $size && ($barlen - $minval) * $size + .5;
say '';
}
continue {
-l, --length=[-]SIZE[%] Trim line contents (between number and bars)
-L, --limit[=(N|-LAST|START-[END])]
Stop output after a number of lines
+ -e, --log Logarithmic (exponential) scale instead of linear
--graph-format=CHAR Glyph to repeat for the graph line
-m, --markers=FORMAT Statistical positions to indicate on bars
--min=N, --max=N Bars extend from 0 or the minimum value if lower
All input is still counted and analyzed for statistics,
but disregarded for padding and bar size.
+=item -e, --log
+
+Logarithmic (I<e>xponential) scale instead of linear
+to compare orders of magnitude.
+
=item --graph-format=<character>
Glyph to repeat for the graph line.
Population and other information for all countries:
curl http://download.geonames.org/export/dump/countryInfo.txt |
- grep -v '^#\s' | column -ts$'\t' -n | barcat -f+2 -u -l150 -s
+ grep -v '^#\s' | column -ts$'\t' -n | barcat -f+2 -e -u -l150 -s
And of course various Git statistics, such commit count by year:
--- /dev/null
+1
+10
+100
+1000
+1e4
+100000
+1e6
--- /dev/null
+ 1
+ 10 ------
+ 100 ----------<
+ 1000 ----------<----+-
+ 1e4 ----------<----+------
+100000 ----------<----+--------->-=
+ 1e6 ----------<----+--------->-=-----
--- /dev/null
+1 2^0
+2 2^1
+4 2^2
+8 2^3
+16 2^4
+32 2^5
+64 2^6
+128 2^7
+256 2^8
+512 2^9
+1024 2^10
+2048 2^11
+4096 2^12
+8192 2^13
+16384 2^14
+32768 2^15
+65536 2^16
+131072 2^17
+262144 2^18
+524288 2^19
+1048576 2^20
+2097152 2^21
+4194304 2^22
+8388608 2^23
+16777216 2^24
+33554432 2^25
+67108864 2^26
+134217728 2^27
+268435456 2^28
+536870912 2^29
+1073741824 2^30
+2147483648 2^31
+4294967296 2^32
+8589934592 2^33
+17179869184 2^34
+34359738368 2^35
+68719476736 2^36
+137438953472 2^37
+274877906944 2^38
+549755813888 2^39
+1099511627776 2^40
+2199023255552 2^41
+4398046511104 2^42
+8796093022208 2^43
+17592186044416 2^44
+35184372088832 2^45
+70368744177664 2^46
+140737488355328 2^47
+281474976710656 2^48
+562949953421312 2^49
+1125899906842624 2^50
+2251799813685248 2^51
+4503599627370496 2^52
+9007199254740992 2^53
+18014398509481984 2^54
+36028797018963968 2^55
+72057594037927936 2^56
+144115188075855872 2^57
+288230376151711744 2^58
+576460752303423488 2^59
+1152921504606846976 2^60
+2305843009213693952 2^61
+4611686018427387904 2^62
+9223372036854775808 2^63
+18446744073709551616 2^64
+36893488147419103232 2^65
--- /dev/null
+ 1 2^0
+ 2 2^1
+ 4 2^2
+ 8 2^3 -
+ 16 2^4 -
+ 32 2^5 -
+ 64 2^6 -
+ 128 2^7 --
+ 256 2^8 --
+ 512 2^9 --
+ 1024 2^10 --
+ 2048 2^11 --
+ 4096 2^12 ---
+ 8192 2^13 ---
+ 16384 2^14 ---
+ 32768 2^15 ---
+ 65536 2^16 ---
+ 131072 2^17 ---<
+ 262144 2^18 ---<
+ 524288 2^19 ---<
+ 1048576 2^20 ---<
+ 2097152 2^21 ---<-
+ 4194304 2^22 ---<-
+ 8388608 2^23 ---<-
+ 16777216 2^24 ---<-
+ 33554432 2^25 ---<-
+ 67108864 2^26 ---<--
+ 134217728 2^27 ---<--
+ 268435456 2^28 ---<--
+ 536870912 2^29 ---<--
+ 1073741824 2^30 ---<--
+ 2147483648 2^31 ---<--+
+ 4294967296 2^32 ---<--+
+ 8589934592 2^33 ---<--+
+ 17179869184 2^34 ---<--+
+ 34359738368 2^35 ---<--+-
+ 68719476736 2^36 ---<--+-
+ 137438953472 2^37 ---<--+-
+ 274877906944 2^38 ---<--+-
+ 549755813888 2^39 ---<--+-
+ 1099511627776 2^40 ---<--+->
+ 2199023255552 2^41 ---<--+->
+ 4398046511104 2^42 ---<--+->
+ 8796093022208 2^43 ---<--+->
+ 17592186044416 2^44 ---<--+->
+ 35184372088832 2^45 ---<--+->-
+ 70368744177664 2^46 ---<--+->-
+ 140737488355328 2^47 ---<--+->-
+ 281474976710656 2^48 ---<--+->-
+ 562949953421312 2^49 ---<--+->--
+ 1125899906842624 2^50 ---<--+->--
+ 2251799813685248 2^51 ---<--+->--
+ 4503599627370496 2^52 ---<--+->--
+ 9007199254740992 2^53 ---<--+->--
+ 18014398509481984 2^54 ---<--+->--=
+ 36028797018963968 2^55 ---<--+->--=
+ 72057594037927936 2^56 ---<--+->--=
+ 144115188075855872 2^57 ---<--+->--=
+ 288230376151711744 2^58 ---<--+->--=
+ 576460752303423488 2^59 ---<--+->--=-
+ 1152921504606846976 2^60 ---<--+->--=-
+ 2305843009213693952 2^61 ---<--+->--=-
+ 4611686018427387904 2^62 ---<--+->--=-
+ 9223372036854775808 2^63 ---<--+->--=--
+18446744073709551616 2^64 ---<--+->--=--
+36893488147419103232 2^65 ---<--+->--=--
--- /dev/null
+1e-5
+1e-4
+1e-3
+.01
+.1
+.2
+.5
+.8
+.9
+.99
+1
+1.1
+1.2
+1.5
+2
--- /dev/null
+1e-5
+1e-4
+1e-3
+ .01
+ .1
+ .2
+ .5
+ .8
+ .9
+ .99
+ 1
+ 1.1 -----
+ 1.2 ---------
+ 1.5 --------------------
+ 2 -----------------------------------