Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

Be consistent. -- Larry Wall in the perl man page


computers / comp.graphics.apps.gnuplot / Re: Filtering and summation of data

SubjectAuthor
* Filtering and summation of datathomas.lehm...@googlemail.com
+- Re: Filtering and summation of dataJörg_Buchholz
`- Re: Filtering and summation of dataJörg_Buchholz

1
Subject: Filtering and summation of data
From: thomas.lehm...@googl
Newsgroups: comp.graphics.apps.gnuplot
Date: Thu, 19 May 2022 18:15 UTC
X-Received: by 2002:a0c:b312:0:b0:45a:a8d7:ecd6 with SMTP id s18-20020a0cb312000000b0045aa8d7ecd6mr5057759qve.100.1652984108930;
Thu, 19 May 2022 11:15:08 -0700 (PDT)
X-Received: by 2002:a05:6902:1084:b0:64d:816c:4077 with SMTP id
v4-20020a056902108400b0064d816c4077mr6030571ybu.162.1652984108764; Thu, 19
May 2022 11:15:08 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.graphics.apps.gnuplot
Date: Thu, 19 May 2022 11:15:08 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=85.132.196.105; posting-account=9eyAowoAAADxZ2nqkXe_TQw63yeWUL6U
NNTP-Posting-Host: 85.132.196.105
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <369741b2-ffe2-4739-a4a5-164b295f8e97n@googlegroups.com>
Subject: Filtering and summation of data
From: thomas.l...@googlemail.com (thomas.lehm...@googlemail.com)
Injection-Date: Thu, 19 May 2022 18:15:08 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2483
View all headers
Hi,

considering data in a table where value are categorized.
I would like to be able a) to filter data for a plot by category
and b) I would like to sum up all values with same category
being able to display it in a plot with box.

Important: the solution should be platform independent;
as an example "awk" or "sed" is not available on all platforms.
Yes python would be possible but I really would prefer the
pure Gnuplot solution if possible.

Kind Regards,
Thomas

Appendix:

What I. have sofar:

<code>
set terminal pngcairo size 1400,1000 enhanced font ",20"
set output "DemoSum.png"

$DemoData << EOD
Timestamp, Category, Value
2022-05-19 05:55:00, test1,  5
2022-05-19 09:16:00, test2, 15
2022-05-19 13:56:00, test3, 10
2022-05-20 05:15:00, test1, 20
2022-05-20 10:58:00, test2,  5
2022-05-20 17:20:00, test3, 25
EOD

set datafile separator ","
set key autotitle columnhead

# a very simple plot functionality
set multiplot layout 2, 1 title "Timestamps And Sums"

# define line style(s)
set style line 1 lc rgb 'grey30' ps 0 lt 1 lw 2
set style line 2 lc rgb 'grey70' lt 1 lw 2
set style fill solid 1.0 border rgb 'grey30'

set timefmt "%Y-%m-%d %H:%M:%S"
set xdata time
set grid

set title "Data based on date and time"
plot $DemoData using 1:3 with linespoint linestyle 1

unset xdata
set title "Data based on categories"
plot $DemoData using 3:xtic(2) with boxes linestyle 1
</code>


Subject: Re: Filtering and summation of data
From: Jörg_Buchholz
Newsgroups: comp.graphics.apps.gnuplot
Organization: A noiseless patient Spider
Date: Mon, 23 May 2022 05:22 UTC
References: 1
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bookwood...@freenet.de (Jörg_Buchholz)
Newsgroups: comp.graphics.apps.gnuplot
Subject: Re: Filtering and summation of data
Date: Mon, 23 May 2022 07:22:47 +0200
Organization: A noiseless patient Spider
Lines: 64
Message-ID: <t6f5n3$f5e$1@dont-email.me>
References: <369741b2-ffe2-4739-a4a5-164b295f8e97n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 23 May 2022 05:22:43 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="71cd530441edab0e9984f1501c6730de";
logging-data="15534"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19XbaSULonZZl9tUz5Z+zVobrJH/inquPA="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.9.0
Cancel-Lock: sha1:4/X1LTR5XGMmeWmlXFcZOqBq36A=
In-Reply-To: <369741b2-ffe2-4739-a4a5-164b295f8e97n@googlegroups.com>
Content-Language: en-GB
View all headers
On 19.05.2022 20:15, thomas.lehm...@googlemail.com wrote:
Hi,

considering data in a table where value are categorized.
I would like to be able a) to filter data for a plot by category
and b) I would like to sum up all values with same category
being able to display it in a plot with box.

Important: the solution should be platform independent;
as an example "awk" or "sed" is not available on all platforms.
Yes python would be possible but I really would prefer the
pure Gnuplot solution if possible.

Kind Regards,
Thomas

Appendix:

What I. have sofar:

<code>
set terminal pngcairo size 1400,1000 enhanced font ",20"
set output "DemoSum.png"

$DemoData << EOD
Timestamp, Category, Value
2022-05-19 05:55:00, test1,  5
2022-05-19 09:16:00, test2, 15
2022-05-19 13:56:00, test3, 10
2022-05-20 05:15:00, test1, 20
2022-05-20 10:58:00, test2,  5
2022-05-20 17:20:00, test3, 25
EOD

set datafile separator ","
set key autotitle columnhead

# a very simple plot functionality
set multiplot layout 2, 1 title "Timestamps And Sums"

# define line style(s)
set style line 1 lc rgb 'grey30' ps 0 lt 1 lw 2
set style line 2 lc rgb 'grey70' lt 1 lw 2
set style fill solid 1.0 border rgb 'grey30'

set timefmt "%Y-%m-%d %H:%M:%S"
set xdata time
set grid

set title "Data based on date and time"
plot $DemoData using 1:3 with linespoint linestyle 1

unset xdata
set title "Data based on categories"
plot $DemoData using 3:xtic(2) with boxes linestyle 1
</code>

stats $DemoData u(strcol(2) eq "test1" ? $3:1/0)
sum_test1 = STATS_sum
print sum_test1

this is one way to get information for one category inside gnuplot.

Jörg


Subject: Re: Filtering and summation of data
From: Jörg_Buchholz
Newsgroups: comp.graphics.apps.gnuplot
Organization: A noiseless patient Spider
Date: Mon, 23 May 2022 11:36 UTC
References: 1
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bookwood...@freenet.de (Jörg_Buchholz)
Newsgroups: comp.graphics.apps.gnuplot
Subject: Re: Filtering and summation of data
Date: Mon, 23 May 2022 13:36:23 +0200
Organization: A noiseless patient Spider
Lines: 112
Message-ID: <t6frjn$u71$1@dont-email.me>
References: <369741b2-ffe2-4739-a4a5-164b295f8e97n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 23 May 2022 11:36:23 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="71cd530441edab0e9984f1501c6730de";
logging-data="30945"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+0xtJgMWE8HCV1FEiVVjRAun1Yg781ZAU="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.9.0
Cancel-Lock: sha1:OI88Voqgw1V2HPst6sMahYNQnTE=
In-Reply-To: <369741b2-ffe2-4739-a4a5-164b295f8e97n@googlegroups.com>
Content-Language: en-GB
View all headers
On 19.05.2022 20:15, thomas.lehm...@googlemail.com wrote:
Hi,

considering data in a table where value are categorized.
I would like to be able a) to filter data for a plot by category
and b) I would like to sum up all values with same category
being able to display it in a plot with box.

Important: the solution should be platform independent;
as an example "awk" or "sed" is not available on all platforms.
Yes python would be possible but I really would prefer the
pure Gnuplot solution if possible.

Kind Regards,
Thomas

Appendix:

What I. have sofar:

<code>
set terminal pngcairo size 1400,1000 enhanced font ",20"
set output "DemoSum.png"

$DemoData << EOD
Timestamp, Category, Value
2022-05-19 05:55:00, test1,  5
2022-05-19 09:16:00, test2, 15
2022-05-19 13:56:00, test3, 10
2022-05-20 05:15:00, test1, 20
2022-05-20 10:58:00, test2,  5
2022-05-20 17:20:00, test3, 25
EOD

set datafile separator ","
set key autotitle columnhead

# a very simple plot functionality
set multiplot layout 2, 1 title "Timestamps And Sums"

# define line style(s)
set style line 1 lc rgb 'grey30' ps 0 lt 1 lw 2
set style line 2 lc rgb 'grey70' lt 1 lw 2
set style fill solid 1.0 border rgb 'grey30'

set timefmt "%Y-%m-%d %H:%M:%S"
set xdata time
set grid

set title "Data based on date and time"
plot $DemoData using 1:3 with linespoint linestyle 1

unset xdata
set title "Data based on categories"
plot $DemoData using 3:xtic(2) with boxes linestyle 1
</code>

Do you mean the second graph like this?

<code>
set terminal pngcairo size 1400,1000 enhanced font ",20"
set output "DemoSum.png"

$DemoData << EOD
Timestamp, Category, Value
2022-05-19 05:55:00, test1,  5
2022-05-19 09:16:00, test2, 15
2022-05-19 13:56:00, test3, 10
2022-05-20 05:15:00, test1, 20
2022-05-20 10:58:00, test2,  5
2022-05-20 17:20:00, test3, 25
EOD

set datafile separator ","
set key autotitle columnhead

# a very simple plot functionality
set multiplot layout 2, 1 title "Timestamps And Sums"

# define line style(s)
set style line 1 lc rgb 'grey30' ps 0 lt 1 lw 2
set style line 2 lc rgb 'grey70' lt 1 lw 2
set style fill solid 1.0 border rgb 'grey30'

set timefmt "%Y-%m-%d %H:%M:%S"
set xdata time
set grid

set title "Data based on date and time"
plot $DemoData using 1:3 with linespoint linestyle 1

unset xdata
set title "Data based on categories"

stats $DemoData u(strcol(2) eq "test1" ? $3:1/0)
sum_test1 = STATS_sum
stats $DemoData u(strcol(2) eq "test2" ? $3:1/0)
sum_test2 = STATS_sum
stats $DemoData u(strcol(2) eq "test3" ? $3:1/0)
sum_test3 = STATS_sum

set xtics in ('test1' 1, 'test2' 2, 'test3' 3)

set boxwidth 1 absolute
set yrange [0:*]
set xrange [0:4]
plot '+' u (1):(sum_test1) w boxes, '+' u (2):(sum_test2) w boxes,  '+'
u (3):(sum_test3) w boxes
unset multiplot
set out
reset
</code>


1
rocksolid light 0.7.2
clearneti2ptor