# GNUPLOT problem

**URL:** <https://community.unix.com/t/gnuplot-problem/298164>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [October 28, 2011, 12:23pm UTC](https://community.unix.com/t/gnuplot-problem/298164 "2011-10-28T12:23:05Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamie\_123](https://community.unix.com/letter_avatar/jamie_123/32/5_5575768a8748004e209b776fc1b2916d.png) [@jamie\_123](https://community.unix.com/u/jamie_123)\
**Post date:** [October 28, 2011, 12:23pm UTC](https://community.unix.com/t/gnuplot-problem/298164/1 "2011-10-28T12:23:05Z")

</div>

Hi,  
Im trying to plot a time series with gnuplot. this is my script

```nohighlight
set xdata time
set yrange [0:]
set timefmt "%H"
set xrange ["11:14:00":"11:15:00"]
set format x "%H:%M:%S"
plot "time_vs_times.txt" using 1:2 title 'Interarrival time' with points lw 2

```

and this is my data  
11:14:18 5  
11:14:19 10  
11:14:20 14  
11:14:21 28  
11:14:22 44  
11:14:23 41  
11:14:24 42  
11:14:25 45  
11:14:26 34  
11:14:27 35  
11:14:28 12  
11:14:29 10  
11:14:30 36  
11:14:31 8  
11:14:32 9  
11:14:33 6  
11:14:34 32  
11:14:35 31  
11:14:36 13  
11:14:37 24  
11:14:38 25  
11:14:39 23  
11:14:40 16  
11:14:41 10  
11:14:42 9  
11:14:43 20  
11:14:44 19  
11:14:45 16  
11:14:46 7  
11:14:47 12  
11:14:48 4  
11:14:49 22  
11:14:50 8  
11:14:51 6  
11:14:52 23  
11:14:53 20  
11:14:54 18  
11:14:55 8  
11:14:56 6  
11:14:57 11  
11:14:58 18  
11:14:59 7

Everytime i try to plot the data, i dont get xaxis from 11:14:00 to 11:15:00, it always gives me a scale from 11:00 to 12:00.

I do not understand why..pl help me..

Thanks!

---

<div class="post-metadata">

**Author:** ![vbe](https://community.unix.com/user_avatar/community.unix.com/vbe/32/266_2.png) [@vbe](https://community.unix.com/u/vbe)\
**Post date:** [October 28, 2011, 12:33pm UTC](https://community.unix.com/t/gnuplot-problem/298164/2 "2011-10-28T12:33:14Z")

</div>

Are you sure this is the right forum? ( I cant imagine a UNIX newbie dealing with this sort of issue...)

---

<div class="post-metadata">

**Author:** ![jamie\_123](https://community.unix.com/letter_avatar/jamie_123/32/5_5575768a8748004e209b776fc1b2916d.png) [@jamie\_123](https://community.unix.com/u/jamie_123)\
**Post date:** [October 28, 2011, 12:38pm UTC](https://community.unix.com/t/gnuplot-problem/298164/3 "2011-10-28T12:38:36Z")

</div>

I'm sorry, but I did not find some forum related directly to this issue. Let me know if there is a better place to put it up.

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/5_5575768a8748004e209b776fc1b2916d.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [October 28, 2011, 1:02pm UTC](https://community.unix.com/t/gnuplot-problem/298164/4 "2011-10-28T13:02:27Z")

</div>

Try leaving off xrange entirely, letting it pick its own range.

Otherwise, I think you have to specify the range in seconds of epoch time. GNUplot has an epoch of 1970 for some things, and an epoch of 2000 for others :wall:

Try just forgetting the year/month/day and just going on the total count of seconds

---

<div class="post-metadata">

**Author:** ![jamie\_123](https://community.unix.com/letter_avatar/jamie_123/32/5_5575768a8748004e209b776fc1b2916d.png) [@jamie\_123](https://community.unix.com/u/jamie_123)\
**Post date:** [October 28, 2011, 1:12pm UTC](https://community.unix.com/t/gnuplot-problem/298164/5 "2011-10-28T13:12:15Z")

</div>

Tried that but still the same output ☹

will try with epoch times soon, thanks 🙂

---------- Post updated at 07:12 PM ---------- Previous update was at 07:04 PM ----------

my epoch has a high resolution 6digits after the decimal, but the resolution that I want is per second..Im actually converting data from epoch to H:M:S so that I can have this. any other way?? ☹

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/5_5575768a8748004e209b776fc1b2916d.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [October 28, 2011, 1:29pm UTC](https://community.unix.com/t/gnuplot-problem/298164/6 "2011-10-28T13:29:06Z")

</div>

If your data has higher resolution than seconds, what does it actually look like? You've only got HH:MM:SS there.

Epoch time is per second.

Try xrange [(11\*60\*60)+(14_60), (11\*60\*60)+(15_60)]

---

<div class="post-metadata">

**Author:** ![jamie\_123](https://community.unix.com/letter_avatar/jamie_123/32/5_5575768a8748004e209b776fc1b2916d.png) [@jamie\_123](https://community.unix.com/u/jamie_123)\
**Post date:** [October 28, 2011, 1:33pm UTC](https://community.unix.com/t/gnuplot-problem/298164/7 "2011-10-28T13:33:27Z")

</div>

The thing is I have my timestamp in epoch and is something like xxxxxxx.xxxxxx the part after the '.' is sub second. So from this i convert it to normal time ignoring the sub second part. and what I want to do is obtain number of times that event has occurred. I use uniq -c -w8 for this.

To do the same in epoch i have to filter in awk just the part before sub seconds and then use uniq on it. trying to figure the awk part now...

---

<div class="post-metadata">

**Author:** ![vgersh99](https://community.unix.com/user_avatar/community.unix.com/vgersh99/32/14851_2.png) [@vgersh99](https://community.unix.com/u/vgersh99)\
**Post date:** [October 28, 2011, 1:41pm UTC](https://community.unix.com/t/gnuplot-problem/298164/8 "2011-10-28T13:41:19Z")

</div>

provide sample input and a desired output.  
most likely you don't need 'uniq' and can do it all in awk.

---

<div class="post-metadata">

**Author:** ![jamie\_123](https://community.unix.com/letter_avatar/jamie_123/32/5_5575768a8748004e209b776fc1b2916d.png) [@jamie\_123](https://community.unix.com/u/jamie_123)\
**Post date:** [October 28, 2011, 3:03pm UTC](https://community.unix.com/t/gnuplot-problem/298164/9 "2011-10-28T15:03:24Z")

</div>

Hi,

managed to crack it.

The data is like this

1319188458.353690 0.46975  
1319188458.823439 0.07558  
1319188458.899017 0.00020  
1319188458.899217 0.00120  
1319188458.900415 0.25879

i split the part before '.' using

```nohighlight
cut -d '.' -f1

```

then used

```nohighlight
awk '{counts[$1]++} END {for (i in counts) {print i, counts}}'

```

put back both the count and time data together using paste -d

and if i plot this data gnuplot works perfectly.

Is there any way to do this all at one go using awk? 🙂 that would be great.

Thanks for your help guys!!

---

<div class="post-metadata">

**Author:** ![vgersh99](https://community.unix.com/user_avatar/community.unix.com/vgersh99/32/14851_2.png) [@vgersh99](https://community.unix.com/u/vgersh99)\
**Post date:** [October 28, 2011, 3:11pm UTC](https://community.unix.com/t/gnuplot-problem/298164/10 "2011-10-28T15:11:13Z")

</div>

```nohighlight
awk '{c[substr($1,1,index($1, ".")-1)]++}END{ for (i in c) print i, c}' myFile

```

---

<div class="post-metadata">

**Author:** ![jamie\_123](https://community.unix.com/letter_avatar/jamie_123/32/5_5575768a8748004e209b776fc1b2916d.png) [@jamie\_123](https://community.unix.com/u/jamie_123)\
**Post date:** [October 31, 2011, 6:24am UTC](https://community.unix.com/t/gnuplot-problem/298164/11 "2011-10-31T06:24:20Z")

</div>

perfect 🙂 thanks 🙂
