Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #3260 > unrolled thread

Histograms series overlap

Started byJoe <joe@invalid.invalid>
First post2016-03-16 15:21 +0000
Last post2016-03-16 17:52 +0000
Articles 3 — 2 participants

Back to article view | Back to comp.graphics.apps.gnuplot


Contents

  Histograms series overlap Joe <joe@invalid.invalid> - 2016-03-16 15:21 +0000
    Re: Histograms series overlap Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2016-03-16 17:02 +0100
      Re: Histograms series overlap Joe <joe@invalid.invalid> - 2016-03-16 17:52 +0000

#3260 — Histograms series overlap

FromJoe <joe@invalid.invalid>
Date2016-03-16 15:21 +0000
SubjectHistograms series overlap
Message-ID<ncbtlu$14fm$1@gioia.aioe.org>
I have following data files (eg. two files one for each serie).
I'm referring to hourly measure records from two stations.

St1.dat
------------------------
2015/03/16 00:00     10
2015/03/16 01:00     25
2015/03/16 02:00     15
------------------------


St2.dat
------------------------
2015/03/16 00:00     5
2015/03/16 01:00     30
2015/03/16 02:00     20
------------------------

I just want one plot with above two series.
X axis will report first colum (date and time)
Y axis second comlumn (measured value)

For each hour I want a "box" with the low part filled with
color of station that reports lower value. And upper part
filled with colour of station that reports higher value.

Let's say we assign color "blu" to Station-1 and "red" to
station-2.

. First hour station1_value > station2_value (10 > 5)

So my box will be "red" in the lower part from 0 to 5 and
"blu" in the upper one, from 5 to 10.

. Second hour station1_value < station2_value (25 < 30)

So my box will be "blu" in the lower part from 0 to 25 and
"red" in the upper one, from 25 to 30.

. Third hour station1_value < station2_value (15 < 20)

So my box will be "blu" in the lower part from 0 to 15 and
"red" in the upper one, from 15 to 20.

Can I obtain a plot like that?


In my tries I noticed an issue: first data series is overlapped
by the last data series I try to plot...


1) First attempt
plot \
     'st1.dat' using 1:3 w boxes lc rgb '#0000aa' title 'st. 1'  ,\
     'st2.dat' using 1:3 w boxes lc rgb '#aa0000' title 'st. 2'

In this case "station 2" is placed in foreground and is plotted over
"station 1" graph. So that I cant see station1 values relative to 2nd
and 3rd hour, because those values are less than 2nd and 3rd hour
"station 2" value.


2) Second attempt
plot \
     'st2.dat' using 1:3 w boxes lc rgb '#aa0000' title 'st. 2'  ,\
     'st1.dat' using 1:3 w boxes lc rgb '#0000aa' title 'st. 1'

The opposite as explained above.. In this case, when station1 data
values are grater than station2 ones, the latter are hidden..


Can I obtain a plot like I've explained above?
Thanks in advance, hope my question is clear enough...

[toc] | [next] | [standalone]


#3261

FromHans-Bernhard Bröker <HBBroeker@t-online.de>
Date2016-03-16 17:02 +0100
Message-ID<dktec3F1762U1@mid.dfncis.de>
In reply to#3260
Am 16.03.2016 um 16:21 schrieb Joe:
> I have following data files (eg. two files one for each serie).
> I'm referring to hourly measure records from two stations.
[...]
> For each hour I want a "box" with the low part filled with
> color of station that reports lower value. And upper part
> filled with colour of station that reports higher value.

I'm afraid combining data from two sets like that is going to be 
impossible with the data residing in two separate input files.  With the 
data in a 3-column file, something like

plot 'file.dat' u 1:(max($2,$3)):(1+($2>$3)) w boxes lc var, \
              '' u 1:(min($2,$3)):(1+($3>=$2)) w boxes lc var

might do it.

I therefore suggest you use external tools like the classic Unix 
utilities 'join' and 'paste' to turn your two files into one, before 
attempting to plot this.

> Can I obtain a plot like I've explained above?

Let's just say that putting the two data sets besides each other (i.e. 
using slimmer boxes, with a bit of horizontal displacement) would be a 
whole lot easier than trying to force gnuplot to do it your way.

[toc] | [prev] | [next] | [standalone]


#3262

FromJoe <joe@invalid.invalid>
Date2016-03-16 17:52 +0000
Message-ID<ncc6gf$1lee$1@gioia.aioe.org>
In reply to#3261
Hans-Bernhard Bröker <HBBroeker@t-online.de> wrote:
> 
> I'm afraid combining data from two sets like that is going to be 
> impossible with the data residing in two separate input files.  With the 
> data in a 3-column file, something like
> 
> plot 'file.dat' u 1:(max($2,$3)):(1+($2>$3)) w boxes lc var, \
>              '' u 1:(min($2,$3)):(1+($3>=$2)) w boxes lc var
> 
> might do it.
> 
> I therefore suggest you use external tools like the classic Unix 
> utilities 'join' and 'paste' to turn your two files into one, before 
> attempting to plot this.
> 
>> Can I obtain a plot like I've explained above?
> 
> Let's just say that putting the two data sets besides each other (i.e. 
> using slimmer boxes, with a bit of horizontal displacement) would be a 
> whole lot easier than trying to force gnuplot to do it your way.

I've just tried a script like follows:

---------------------------
min(x,y) = (x < y) ? x : y
max(x,y) = (x > y) ? x : y
set xtics 3600*8 rotate by 80 right
set xdata time
set timefmt "%d/%m/%Y %H:%M"
set format x "%d/%m/%Y - %H:%M"
set yrange [-1:35]
set ytics 5 out
plot 'data.tmp' u 1:(max($3,$4)):(1+($3>$4)) w boxes lc var, \
              '' u 1:(min($3,$4)):(1+($4>=$3)) w boxes lc var
---------------------------------------------------------------

$ cat data.tmp 
--------------------------------------
16/01/2015 10:00         0.00    0.40
16/01/2015 11:00         0.00    0.00
16/01/2015 12:00         0.20    2.40
16/01/2015 13:00         0.80    5.80
16/01/2015 14:00         0.80    2.60
16/01/2015 15:00         0.00    0.00
16/01/2015 16:00         0.20    1.00
16/01/2015 17:00         0.20    0.20
16/01/2015 18:00         1.80    1.00
16/01/2015 19:00         2.20    2.20
16/01/2015 20:00         19.60   6.60
16/01/2015 21:00         20.00   9.20
16/01/2015 22:00         11.60   21.20
16/01/2015 23:00         8.80    6.20
17/01/2015 00:00         5.20    2.20
17/01/2015 01:00         0.40    0.80
17/01/2015 02:00         0.00    0.20
17/01/2015 03:00         0.00    0.00
17/01/2015 04:00         0.00    0.00
17/01/2015 05:00         0.00    0.00
17/01/2015 06:00         0.00    0.00
17/01/2015 07:00         0.00    0.00
17/01/2015 08:00         0.00    0.00
17/01/2015 09:00         0.00    0.00
--------------------------------------

data.tmp is created by using sed, cut, paste... as you suggested.
Output plot is exactly what I was looking for.

Thanks a lot for your reply.

I have to plot many data: hourly measurements of about one or more
years. So 10000 or more data.
Moreover I often have to consider more than just two measurement
stations, let's say 3 or 4 stations.
For this reason, I don't have much horizontal space to put 3 or 4
boxes for one single "datetime" tic.

How can I adjust your plot command to work with more than two
stations?
We will have a data.tmp file with values on column 2nd, 3rd, 4th,
5th, 6th...

Thanks again!

[toc] | [prev] | [standalone]


Back to top | Article view | comp.graphics.apps.gnuplot


csiph-web