Gnuplot Time Data Question


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Gnuplot Time Data Question
# 1  
Old 05-16-2013
Gnuplot Time Data Question

I have a data file of the following format:
Code:
servername,2013-05-11 17:46:03,SomeText,195,195,11,202 
servername,2013-05-11 17:47:03,SomeText,192,192,23,103 
servername,2013-05-11 17:48:03,SomeText,189,190,14,117 
servername,2013-05-11 17:49:03,SomeText,196,195,24,231 
... 
...

I want to plot a graph where the x-axis has the time (%H:%M:%S) values (don't need the date part. The y-axis should have the two last columns.

Here's a sample bash script I have to run this.
Code:
#!/usr/bin/bash 

basedir="app-stats" 
termsize="1200,600" 
xtics="1800" 
type="proc" 
range="*:" 

echo $server-$filenm.data 

gnuplot -persist << EOF 
reset 
set terminal pngcairo size ${termsize} enhanced font 'Verdana,8' 
set xdata time 
set timefmt "%Y/%m/%d %H:%M:%S'" 
set format x "%H:%M:%S" 
set datafile separator "," 
set xtics nomirror rotate 
set xtics ${xtics} 
set ytics nomirror 
set y2tics 
set grid xtics lt 0 lw 1 lc rgb "#000000" 
set grid ytics lt 0 lw 1 lc rgb "#880000" 
set grid y2tics lt 0 lw 1 lc rgb "#008800" 
set ylabel 'servername' 
set y2label 'proc' 
set auto fix 
set offsets graph 0, graph 0, graph 0.1, graph 0 
show offsets 
set title "App Statistics for ${host}" enhanced font 'Verdana Bold,10' 
set label "Date: 02/07/13" at screen 0.01, 0.97 
set label "SomeLabel" at screen 0.98, 0.97 right 
set key inside center bottom horizontal Right noreverse enhanced autotitles box linetype -1 linewidth 1.000 

set output "$server-$filenm.png" 
plot '$server-$filenm.data' using 1:6 title 'proc/s'  with lines lt rgbcolor "light-red" lw 2, \ 
     '$server-$filenm.data' using 1:7 axes x1y2 title 'cswch/s' with lines lt rgbcolor "blue" lw 2 
EOF 

exit


I can plot this successfully if the time data doesn't contain "date space time" but only time and the server name isn't the first field (see below).
Code:
17:46:03,SomeText,195,195,11,202 
17:47:03,SomeText,192,192,23,103 
... 
...

My questions are:

1. Can I have a non-xdata column before the xdata column like "servername" and identify where the xdata column is in the "using (1:6)" statement, substituting 1:6 with say, 3:6 if the xdata column is the third column? I'm not able to get this to work.

2. If the first column is

2013-05-11 17:46:03, how can I get it to plot correctly using either
Code:
set timefmt "%Y/%m/%d %H:%M:%S'" 
set format x "%H:%M:%S"

or
Code:
set timefmt "%Y/%m/%d %H:%M:%S'" 
set format x "%Y/%m/%d %H:%M:%S"

Cheers,
Beery

Last edited by Franklin52; 05-17-2013 at 03:26 AM.. Reason: Please use code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Find gaps in time data and replace missing time value and column 2 value by interpolation in awk

Dear all, I am kindly seeking assistance on the following issue. I am working with data that is sampled every 0.05 hours (that is 3 minutes intervals) here is a sample data from the file 5.00000 15.5030 5.05000 15.6680 5.10000 16.0100 5.15000 16.3450 5.20000 16.7120 5.25000... (4 Replies)
Discussion started by: malandisa
4 Replies

2. Shell Programming and Scripting

Gnuplot question

Hi! Let's say I have these two columns in file.txt 0 1 1 5 2 10 3 15 4 20 5 25 in gnuplot, i would plot usingplot 'file.txt' u 1:2 If I wanted to add a label to the y-axis I would useset label "Ef" at 0.0,7.0 However, I want the label Ef to be on the otherside of the y-axis. Not... (0 Replies)
Discussion started by: sidiq1983
0 Replies

3. UNIX and Linux Applications

Gnuplot Same Data Two Axes Different Units)

I'm pretty familiar with Gnuplot, but I've never actually come across a reasonable solution to this problem and I'm hoping someone can help me out! I think it's because I don't know how to pose the problem neatly, so please bare with me. Also new to the forum....so yeah... I have one data set (x... (3 Replies)
Discussion started by: TC69
3 Replies

4. Shell Programming and Scripting

Problem creating graph with gnuplot with time on x-axis

Let me start by saying I'm new to gnuplot and not very good at unix at all.. Anyway, I'm each minute measuring temperature and humidity and saves the last 60 readings along with time in a textfile, values_minute. The contents of the file is formatted like this: time temperature humidity ... (8 Replies)
Discussion started by: hakro807
8 Replies

5. Shell Programming and Scripting

Parsing file: preparing data for charts (gnuplot, calc,...)

Hi there, I have files (tsv) like this: CTLPort IO Rate(IOPS) Read Hit(%) Write Hit(%) Timestamp 0A 136 97 100 09:36:48 0B 3 100 100 09:36:48 0C 88 35 100 09:36:48 0A 87 100 100 09:37:49 0B 3 97 100 09:37:49 0C 83 45 100 09:37:49 0A 108 83 100 09:38:48 0B 3 100 100 09:38:48... (1 Reply)
Discussion started by: gray380
1 Replies

6. Shell Programming and Scripting

placeholder in gnuplot data

My input data has occasional holes in it, spots where a sensor couldn't be read. These are ERR in the data file instead of a floating point number. What should I change them to, for gnuplot to ignore these values instead of whining about them? (1 Reply)
Discussion started by: Corona688
1 Replies

7. UNIX for Dummies Questions & Answers

Fitting data in gnuplot with xyerrorbars

I was looking at the examples that show how to fit data using gnuplot (ex: gnuplot / misc (2E)) but I can't find a place that shows what to do if I have ranges for the x and y error bars. I tried the common sense: gnuplot> fit f(x) "data.txt" using 3:6:4:5:7:8 via a,b ... (8 Replies)
Discussion started by: cosmologist
8 Replies

8. Programming

GNUPLOT- how to change the style of data points

Hi, I am trying to arrange my graphs with GNUPLOT. Although it looked like simple at the beginning, I could not figure out an answer for the following: I want to change the style of my data points (not the line, just exact data points) The terminal assigns first + and then x to them but what I... (0 Replies)
Discussion started by: natasha
0 Replies

9. UNIX for Dummies Questions & Answers

sar Vs. gnuplot time format

Hi, I want to generate gnuplot graph from sar data. My problem is the time format. 1- Gnuplot doesn't support the sar format (01:00:59 AM/PM) 2- Sar doesn't provide a switch to choose the format. The only way to do it is by exporting LANG=fr_FR. Since I have other apps running and... (0 Replies)
Discussion started by: foxmtl
0 Replies

10. UNIX for Advanced & Expert Users

Gnuplot question: plotting 3D data in map view

I have a simple gnuplot question. I have a set of points (list of x,y,z values; irregularly spaced, i.e. no grid) that I want to plot. I want the plot to look like this: - map view (no 3D view) - color of each point should depend on z-value. - I want to define my own color scale - plot should... (1 Reply)
Discussion started by: karman
1 Replies
Login or Register to Ask a Question