Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: histogram

by alperyilmaz (Initiate)
on Nov 19, 2009 at 17:18 UTC ( [id://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,

Replies are listed 'Best First'.
Re^2: histogram
by polettix (Vicar) on Nov 23, 2009 at 23:45 UTC

    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?

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-07-20 22:06 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.