Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: histogram

by alperyilmaz (Initiate)
on Nov 19, 2009 at 17:18 UTC ( #808215=note: print w/ replies, xml ) Need Help??


in reply to histogram

i want to add option ASCII stars, to make it graphical, like this: -a|--ascii <num of stars> In this case, let's say I want 100 stars maximum.. what number do i need to divide the numeric values to get number of stars per lane? thanks,


Comment on Re: histogram
Re^2: histogram
by polettix (Vicar) on Nov 23, 2009 at 23:45 UTC
    Hi

    if you always want your highest category to be represented by 100 stars, you have to normalise all the values multiplying by 100 / $max_value, like this (around line 98):

    if ($config{ascii}) { require List::Util; my $max_value = List::Util::max(@frequencies); for my $index (0 .. $#frequencies) { my $length = $frequencies[$index] * $config{ascii} / $max_value; print {*STDOUT} $labels[$index], "\t", '*' x $length, "\n"; } exit 0; }
    Of course, you have to add the option at the beginning.

    perl -ple'$_=reverse' <<<ti.xittelop@oivalf

    Io ho capito... ma tu che hai detto?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://808215]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2014-11-24 01:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (135 votes), past polls