help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Graphing a list of values


From: hancooper
Subject: Graphing a list of values
Date: Sat, 18 Sep 2021 08:26:42 +0000

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Saturday, September 18, 2021 5:41 AM, Alex fxmbsw7 Ratchev 
<fxmbsw7@gmail.com> wrote:

> here my awk try
>
> t=( 1 100 20 50 ) ; gawk -v RS=\ -v c=15 -v S=+ '{ m = m < $1 ? $1 : m ;
> s[NR] = $1 } END { while ( ++i <= NR ) print l( int( s[i] / m * c ) ) }
> function l( n, t ) { t = sprintf( "%-" n "s", "" ) ; gsub( " ", S , t ) ;
> return t }' <<<"${t[*]}"
>
> +++++++++++++++
> +++
> +++++++

Have found this try, thank you.


> On Sat, Sep 18, 2021, 07:26 Alex fxmbsw7 Ratchev fxmbsw7@gmail.com wrote:
>
> > you have a max_mb per maxcols too ?
> > i wanted to give it a try but the max_mb is missing, for scaling right
> > .. ?
> > On Sat, Sep 18, 2021, 06:09 hancooper via help-bash@gnu.org wrote:
> >
> > > I have an array composed of the following elements and want to generate a
> > > graph of the values, distributed over a number of columns (ncols=80)
> > >
> > >     + 3665.64686592 MB
> > >     + 1261.64520768 MB
> > >     + 96.35131584 MB
> > >     + 61.17171840 MB
> > >     + 99.81615072 MB
> > >     + 541.22517696 MB
> > >     + 1067.42695488 MB
> > >     + 462.11600448 MB
> > >     + 970.72017120 MB
> > >     + 1539.70699584 MB
> > >     + 2207.06856864 MB
> > >     + 2522.07166848 MB
> > >     + 645.12725472 MB
> > >     + 104.71848192 MB
> > >     + 70.59747552 MB
> > >     + 44.05066848 MB
> > >
> > >
> > > For instance
> > >
> > >     + 10 MB
> > >     + 50 MB
> > >     + 100 MB
> > >
> > >
> > > Here would be the result with `ncols=10`
> > >
> > >     *
> > >     *****
> > >     **********
> > >
> > >
> > > Have started with the following, but have to modify to take values from
> > > an array. Using `awk` seems as the better way to do this.
> > >
> > >     oaggr=("+ 659.28737472 MB" "+ 316.94840736 MB" "+ 163.69489344 MB")
> > >     awk '{$2=sprintf("%-*s", $2, ""); gsub(" ", "=", $2); \\
> > >     printf("%-10s%s\\n", $1, $2)}' file
> > >





reply via email to

[Prev in Thread] Current Thread [Next in Thread]