LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-15-2009, 03:06 PM   #1
javawench
LQ Newbie
 
Registered: Jan 2009
Posts: 5

Rep: Reputation: 0
Question Trouble with Gnuplot and time data


I am creating histograms to report mail traffic across the mail hubs. They come out beautifully if I don't use dates. I have run out of ideas of what to change. The Gnuplot software states in the using spec that the date format can not be specified in the using statement but I'm getting an error "need full using spec for x time data"

Any insight would be appreciated.

Javawench

I have defined the following for gnuplot
set terminal png
set output 'histograms.2.png'
set boxwidth 0.9 absolute
set style fill solid 1.00 border -1
set style histogram clustered gap 2 title offset character 0, 0, 0
set style data histograms
#set xdata time
#set timefmt "%Y-%m-%d"
set xtics border in scale 1,0.5 nomirror
set colorbox vertical origin screen 0.9, 0.2, 0 size screen 0.05, 0.6, 0
set title "Mail Statistics"
set grid
plot 'input.dat' using 1:xtic(1) t '',''u 2 ti col, ''u 3 ti col

input.dat sample is
Date East West
2009-01-05 7127 5851
2009-01-06 7646 6786
2009-01-07 8439 8250
2009-01-08 9174 8495
2009-01-09 7508 7269
2009-01-10 2530 2870
2009-01-11 2828 2811
 
Old 01-15-2009, 08:07 PM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044
Googling yields that it is not a bug but something which is not possible because of the inability to specify the correct x values for multiple columns.

About a year ago, when Gnuplot 4.1 was not available yet for my distro and hence the multicolumn not available, I solved it like this:

I created multiple input files, one for each range. In the first column of each file I specified the time in seconds. Then in the second (and third and so on) I applied an offset to the seconds by adding and substracting a number of seconds which the bars had to shift to the left or the right. For example, if you have 10 days in your plot, you might want to shift each bar by a quarter day, or 21600 seconds, 43200 seconds etc.

Eventually, this became my plot file:

Code:
set xdata time
set timefmt "%s"
set format x "%b %y"
set xtics 2628000
set boxwidth 0.15 relative
set style fill solid 1.00 border
set xtics rotate
set grid ytics
set bmargin 7
set label "graph created with gnuplot 4.0" at screen 0.6,0.05
set yrange [97.5:100.5]
set ylabel "beschikbaarheid (%)"
set xlabel "maand" 0,-1.4
set title "$1"
set terminal png small size 640,480 \
             xffffff x000000 x404040 \
             xe00000 x00e000 x0000e0 \
             xe0e000 xe000e0
set output "$0.png"
set key left
plot "$0_tx1.plt" using 1:2 title 'PH1' with boxes, "$0_tx2.plt" using 1:2 title 'PH2' with boxes, "$0_tx3.plt" using 1:2 title 'ABB' wi
th boxes, "$0_tx4.plt" using 1:2 title 'TH1' with boxes, "$0_tx5.plt" using 1:2 title 'TH2' with boxes
$0_tx2.plt are the names of the data files, I used the "$0" syntax because I passed the file name externally. Furthermore this plot shows data for a year, hence the large value for xtics. Below each set of bars the date appear in "month year" format.

http://pdis.rnw.nl/~hansl/links/mr_J5Rli8.png

As you can see, some bars are omitted, that is on purpose as no data is available. All the bars remain in the same offset position, the gaps are not closed.

This is the contents of the data files:

Code:
1182348000  98.9798
1185026400  99.3491
1187704800  99.673
1190296800  99.6147
1192975200  98.9541
1195567200  100
1198245600  99.648
1200924000  99.565
1203429600  99.7407
1206108000  0
1208700000  0
1211378400  0
1213970400  0
Code:
1182798000  99.1756
1185476400  99.9569
1188154800  100
1190746800  0
1193425200  0
1196017200  0
1198695600  0
1201374000  0
1203879600  0
1206558000  0
1209150000  0
1211828400  0
1214420400  0
Code:
1183248000  99.9055
1185926400  99.9212
1188604800  99.9036
1191196800  99.9234
1193875200  99.9461
1196467200  99.975
1199145600  99.9478
1201824000  99.912
1204329600  99.9177
1207008000  99.7549
1209600000  99.8632
1212278400  99.9578
1214870400  99.9025
Code:
1183698000  0
1186376400  99.8479
1189054800  99.9781
1191646800  99.9121
1194325200  99.4444
1196917200  99.9573
1199595600  99.9575
1202274000  99.4175
1204779600  99.8023
1207458000  99.8723
1210050000  99.8026
1212728400  99.9485
1215320400  99.9825
Code:
1184148000  0
1186826400  0
1189504800  0
1192096800  99.9133
1194775200  99.9541
1197367200  99.8715
1200045600  99.9925
1202724000  99.9754
1205229600  99.901
1207908000  99.6784
1210500000  99.8914
1213178400  99.9476
1215770400  99.9542
jlinkels
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Time-based range in gnuplot? Lordandmaker Linux - Software 2 12-18-2008 01:16 PM
gnuplot - do multiple plots from data file with built-in commands Meson Linux - Software 2 07-30-2008 04:52 PM
gnuplot, pull X data from file, specify Y data at cmd line? hedpe Programming 5 03-16-2007 12:32 AM
gnuplot: how to label x-axis with strings from data file? hedpe Linux - Software 2 07-11-2006 11:21 AM
Trouble adding drive with data vrivett Red Hat 1 10-16-2004 05:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration