Plotting Data within UNIX


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Plotting Data within UNIX
# 1  
Old 01-28-2009
Plotting Data within UNIX

I have a set of data that looks similar to the following in UNIX:

0.12_0.008_fall_ff.out:bisect return: 0.08056640625
0.12_0.04_fall_ff.out:bisect return: 0.07470703125
0.12_0.12_fall_ff.out:bisect return: 0.06298828125
0.12_0.24_fall_ff.out:bisect return: 0.05126953125

Previously I have been dumping this data directly into Excel in Windows and plotting the numeric data. My manager just decided that it would be better to have the plot shown within UNIX and even better if the whole thing can be done by simply executing a script. I was looking at several different utilities like plot, gnuplot, etc but failed to even import that data above to any of the utilities to create plots. Does anyone have recommendation on a great tool to plot hundreds of lines of numeric data?

I am looking at graph command right now, but it appears that it only takes x-y plots and therefore needs two sets of data. Otherwise graph appears to be the only utility I know so far that can take data from text files. (gnuplot 4.2 does too, but my company only has 4.0) Please correct me if I am wrong.

Last edited by EDALBNUG; 01-28-2009 at 06:58 PM..
# 2  
Old 01-29-2009
You might consider Chart Director:

ChartDirector for PHP - Links
# 3  
Old 01-29-2009
Hi.

One way to have gnuplot read data from a file:
Code:
#!/usr/bin/env bash

# @(#) s1       Demonstrate feed data to gnuplot.
# See:
# http://www.gnuplot.info/docs/node131.html

echo
set +o nounset
LC_ALL=C ; LANG=C ; export LC_ALL LANG
echo "Environment: LC_ALL = $LC_ALL, LANG = $LANG"
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version "=o" $(_eat $0 $1) cut gnuplot
set -o nounset
echo

FILE=${1-data1}

echo " Raw data file $FILE:"
cat $FILE

# Create a header line, extract data, feed into gnuplot.

echo 'set terminal dumb 30 15 ; plot "-"' >t1
cut -f3 -d " " $FILE >>t1

echo
echo " Dataset as fed into gnuplot:"
cat t1

echo
echo " Results:"
gnuplot < t1

exit 0

Producing:
Code:
% ./s1

Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: Linux, 2.6.11-x1, i686
Distribution        : Xandros Desktop 3.0.3 Business
GNU bash 2.05b.0
cut (coreutils) 5.2.1
gnuplot 4.0 patchlevel 0

 Raw data file data1:
0.12_0.008_fall_ff.out:bisect return: 0.08056640625
0.12_0.04_fall_ff.out:bisect return: 0.07470703125
0.12_0.12_fall_ff.out:bisect return: 0.06298828125
0.12_0.24_fall_ff.out:bisect return: 0.05126953125

 Dataset as fed into gnuplot:
set terminal dumb 30 15 ; plot "-"
0.08056640625
0.07470703125
0.06298828125
0.05126953125

 Results:


  0.085 ++-+--+--+---+--+-++
        A  +  + "-"  +A +  +
   0.08 ++                ++
  0.075 ++    A           ++
        |                  |
   0.07 ++                ++
  0.065 ++                ++
        |            A     |
   0.06 ++                ++
  0.055 ++                ++
        +  +  +  +   +  +  +
   0.05 ++-+--+--+---+--+-+A
        0 0.5 1 1.5  2 2.5 3

Best wishes ... cheers, drl
# 4  
Old 01-29-2009
Thanks for the help drl. I tried adding line number in front of each line by using nl command and plotted in gnuplot using 1:4, but it looks like gnuplot can take a single list of variables and plot just fine. I tried adding plot "-" at the very beginning of my data file and do gnuplot < file at my terminal, but I think the graph tried to come out (output to X by default?) and closed immediately. Is this the reason why you opted for the dumb terminal output option? I would like to have gnuplot spit out the plot in X if possible (using the gnuplot < file way), since anything more than a couple data points, not to mention thousands, become unreadable in dumb terminal.
# 5  
Old 01-29-2009
Hi.

Yes, I used the dumb terminal to show the results from the general flow of data.

This will produce a Postscript plot on file t2, and then ghostscript, gs, can be used to look at it:
Code:
#!/usr/bin/env bash

# @(#) s1       Demonstrate feed data to gnuplot.
# See:
# http://www.gnuplot.info/docs/node131.html

echo
set +o nounset
LC_ALL=C ; LANG=C ; export LC_ALL LANG
echo "Environment: LC_ALL = $LC_ALL, LANG = $LANG"
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version "=o" $(_eat $0 $1) cut gnuplot gs
set -o nounset
echo

FILE=${1-data1}

echo " Raw data file $FILE:"
cat $FILE

# Create a header line, extract data, feed into gnuplot.

# echo 'set terminal dumb 30 15 ; plot "-"' >t1
echo 'set terminal postscript eps colour; plot "-"' >t1
cut -f3 -d " " $FILE >>t1

echo
echo " Dataset as fed into gnuplot:"
cat t1

echo
echo " Results:"
gnuplot < t1 > t2
gs t2

exit 0

Look over the documentation to see what other devices can be used, gnuplot ... cheers, drl
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Fun with terminal plotting JSON data at the command line

One of the great thing about unix is the ability to pipe multiple programs together to manipulate data. Plain, unstructured text is the most common type of data that is passed between programs, but these days JSON is becoming more popular. I thought it would be fun to pipe together some command... (1 Reply)
Discussion started by: kbrazil
1 Replies

2. Slackware

Grace and plotting

I am making mathematical graphics in grace, all is working, but my curves are not totally smooth,..i have equal problem in gnuplot,... can i do anything??:confused: (4 Replies)
Discussion started by: gitac
4 Replies

3. UNIX for Dummies Questions & Answers

Help with Plotting a graph using Perl

Dear all, I have a hash in my data file and I'd like to output the data contained within as a graph (can be lines or histogram form) but I dont know how to do this with Perl. Can somone suggest how I can have a graph with Keys of the hash being on the X-axis and the Values for the keys plotted on... (1 Reply)
Discussion started by: pawannoel
1 Replies

4. UNIX for Dummies Questions & Answers

Plotting boxes in gnuplot

When I plot a set of data in gnuplot from a file like: 1 5 2 3 4 6 5 1 using plot "file.txt" w boxes I would expect that at the x value of 3 it will go to a value of 0 for y... but it doesn't. Is there a way to fix that, or do I actually have to type by hand an... (1 Reply)
Discussion started by: cosmologist
1 Replies

5. UNIX for Dummies Questions & Answers

Help with extracting data and plotting

I have attached a txt file, what I would like to be able to do is: 1. Extract Data from Columns labeled E/N and Ko into a new file 2. Then in the new file I would like to be able to plot E/N on the X axis and Ko on the y axis. 3. Lastly I would like to be able to extract multiple data sets and... (6 Replies)
Discussion started by: gingburg
6 Replies

6. Shell Programming and Scripting

Extracting ICMP Output for Plotting

Dear, I want to perform a plotting using xgraph, and the plotting data (ping.txt) is as below. For the graph I just want to plot the time for x-axis (line count) and the RTT for y-axis (time in ms). Below are script i write for that purpose but it seen did not work. Any guide for me because i... (1 Reply)
Discussion started by: Paris Heng
1 Replies

7. 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

8. Shell Programming and Scripting

automated plotting

Hi, I would like to make a lot of plots with for instance xmgrace and don't know how. I have a directory with about 500 data files with the same structure and I want to plot always the same columns. I don't know how to call xmgrace to produce a, say, gif plot of the columns 3 and 4 of... (2 Replies)
Discussion started by: pau
2 Replies

9. UNIX for Dummies Questions & Answers

Help Plotting

I need to plot some files with the extension .plot, which I believe is a UNIX Plot(5) extension. Is UNIX Plot(5) something that I must download, or is it already built into UNIX? If it is already built in, is there a trick to actually plotting the files? Is there anything online that I could... (0 Replies)
Discussion started by: evenkolder
0 Replies
Login or Register to Ask a Question