make mlr bar arguments resemble mlr histogram arguments

This commit is contained in:
John Kerl 2015-10-27 17:06:21 -04:00
parent 81875c0ea4
commit f267ba1965
4 changed files with 29 additions and 34 deletions

View file

@ -25,7 +25,7 @@ static mapper_t* mapper_bar_parse_cli(int* pargi, int argc, char** argv);
#define DEFAULT_FILL_CHAR '*'
#define DEFAULT_OOB_CHAR '#'
#define DEFAULT_BLANK_CHAR ' '
#define DEFAULT_BLANK_CHAR '.'
#define DEFAULT_LO 0.0
#define DEFAULT_HI 100.0
#define DEFAULT_WIDTH 40
@ -43,13 +43,13 @@ static void mapper_bar_usage(FILE* o, char* argv0, char* verb) {
fprintf(o, "Replaces a numeric field with a number of asterisks, allowing for cheesy bar plots.\n");
fprintf(o, "These align best with --opprint or --oxtab output format.\n");
fprintf(o, "Options:\n");
fprintf(o, "-f {a,b,c} Field names to convert to bars.\n");
fprintf(o, "-c {character} Fill character: default '%c'.\n", DEFAULT_FILL_CHAR);
fprintf(o, "-x {character} Out-of-bounds character: default '%c'.\n", DEFAULT_OOB_CHAR);
fprintf(o, "-b {character} Blank character: default '%c'.\n", DEFAULT_BLANK_CHAR);
fprintf(o, "-l {lo} Lower-limit value for min-width bar: default '%lf'.\n", DEFAULT_LO);
fprintf(o, "-u {hi} Upper-limit value for max-width bar: default '%lf'.\n", DEFAULT_HI);
fprintf(o, "-w {n} Bar-field width: default '%d'.\n", DEFAULT_WIDTH);
fprintf(o, "-f {a,b,c} Field names to convert to bars.\n");
fprintf(o, "-c {character} Fill character: default '%c'.\n", DEFAULT_FILL_CHAR);
fprintf(o, "-x {character} Out-of-bounds character: default '%c'.\n", DEFAULT_OOB_CHAR);
fprintf(o, "-b {character} Blank character: default '%c'.\n", DEFAULT_BLANK_CHAR);
fprintf(o, "--lo {lo} Lower-limit value for min-width bar: default '%lf'.\n", DEFAULT_LO);
fprintf(o, "--hi {hi} Upper-limit value for max-width bar: default '%lf'.\n", DEFAULT_HI);
fprintf(o, "-w {n} Bar-field width: default '%d'.\n", DEFAULT_WIDTH);
}
// ----------------------------------------------------------------
@ -65,13 +65,13 @@ static mapper_t* mapper_bar_parse_cli(int* pargi, int argc, char** argv) {
char* verb = argv[(*pargi)++];
ap_state_t* pstate = ap_alloc();
ap_define_string_array_flag(pstate, "-f", &pfield_names);
ap_define_string_flag(pstate, "-c", &fill_string);
ap_define_string_flag(pstate, "-x", &oob_string);
ap_define_string_flag(pstate, "-b", &blank_string);
ap_define_double_flag(pstate, "-l", &lo);
ap_define_double_flag(pstate, "-u", &hi);
ap_define_int_flag(pstate, "-w", &width);
ap_define_string_array_flag(pstate, "-f", &pfield_names);
ap_define_string_flag(pstate, "-c", &fill_string);
ap_define_string_flag(pstate, "-x", &oob_string);
ap_define_string_flag(pstate, "-b", &blank_string);
ap_define_double_flag(pstate, "--lo", &lo);
ap_define_double_flag(pstate, "--hi", &hi);
ap_define_int_flag(pstate, "-w", &width);
if (!ap_parse(pstate, verb, pargi, argc, argv)) {
mapper_bar_usage(stderr, argv[0], verb);

View file

@ -357,20 +357,20 @@ a=1,c=2,b=3
e=4,d=5
a=6,c=7,b=8
mlr --opprint bar -f x,y -l 0 -u 1 ./reg_test/input/abixy
mlr --opprint bar -f x,y --lo 0 --hi 1 ./reg_test/input/abixy
a b i x y
pan pan 1 ************* *****************************
eks pan 2 ****************************** ********************
wye wye 3 ******** *************
eks wye 4 *************** *****
wye pan 5 ********************** **********************************
zee pan 6 ********************* *******************
eks zee 7 ************************ *******
zee wye 8 *********************** ***************************************
hat wye 9 * *****************************
pan wye 10 ******************** **************************************
pan pan 1 *************........................... *****************************...........
eks pan 2 ******************************.......... ********************....................
wye wye 3 ********................................ *************...........................
eks wye 4 ***************......................... *****...................................
wye pan 5 **********************.................. **********************************......
zee pan 6 *********************................... *******************.....................
eks zee 7 ************************................ *******.................................
zee wye 8 ***********************................. ***************************************.
hat wye 9 *....................................... *****************************...........
pan wye 10 ********************.................... **************************************..
mlr --opprint bar -f x,y -c c -x x -b b -l 0.1 -u 0.9 -w 20 ./reg_test/input/abixy
mlr --opprint bar -f x,y -c c -x x -b b --lo 0.1 --hi 0.9 -w 20 ./reg_test/input/abixy
a b i x y
pan pan 1 ccccccbbbbbbbbbbbbbb cccccccccccccccbbbbb
eks pan 2 ccccccccccccccccbbbb ccccccccccbbbbbbbbbb

View file

@ -123,8 +123,8 @@ run_mlr --csvlite rename -r -g '"e"i,EEE' $indir/date1.csv $indir/da
run_mlr regularize $indir/regularize.dkvp
run_mlr --opprint bar -f x,y -l 0 -u 1 $indir/abixy
run_mlr --opprint bar -f x,y -c c -x x -b b -l 0.1 -u 0.9 -w 20 $indir/abixy
run_mlr --opprint bar -f x,y --lo 0 --hi 1 $indir/abixy
run_mlr --opprint bar -f x,y -c c -x x -b b --lo 0.1 --hi 0.9 -w 20 $indir/abixy
# ----------------------------------------------------------------
announce TRIVIAL RETAINERS

View file

@ -13,11 +13,6 @@ TOP OF LIST
! join on partial value-field matches
MINOR: popall and/or xfer method; use @ sort; replace append @ streamer & where else?
- rid of sllv_append
- decide where to put the free of pthat (caller or callee)
- rid of while-pop loops
- sllv_xfer UT
x bar --lo/--hi : imitate histogram
x bar bg char default to '.'
x bar fg char default to 'o'