LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-03-2010, 09:11 AM   #1
Exoskeletor
LQ Newbie
 
Registered: Jan 2010
Posts: 6

Rep: Reputation: 0
how to create this graph in gnuplot


hi guys. i need a script that takes data fom a file mydata.dat and create a graph. the content of mydata.dat is
Bin Data1 Data2 Data3
0 12 12.3 2
1 3 34.1 0
2 5 45.3 4
3 7 33.3 5
4 12 20 6
5 2 30.1 2
6 9 17.9 4
7 20 43.0 10
8 21 35.0 3
9 2 23.7 10

then it asks from the user to select which colums with use for x and which for y. the x and y titles must be generated automaticly by the names of each column from the first line of mydata.dat the limits must also be auto generated by the width of the column (for example for data2 is 12-45). in the end for graph title must shown the current time and date in this format:
Date: Dec. 15, 2009,
Time: 14:05:23.
So it asks for the user the columns and in the end it shows the graph with the above settings. can someone help me to do it?
 
Old 01-03-2010, 09:59 AM   #2
harry edwards
Member
 
Registered: Nov 2007
Location: Lincolnshire, UK
Distribution: CentOS, Fedora, and Suse
Posts: 365

Rep: Reputation: 48
The manual covers the plotting question you pose http://www.gnuplot.info/docs/gnuplot.html. Also, there are loads of examples to use as inspiration http://gnuplot.sourceforge.net/demo/. The other items can be achieved in a simple bash script http://www.linuxconfig.org/Bash_scripting_Tutorial.

Last edited by harry edwards; 01-03-2010 at 10:01 AM.
 
Old 01-03-2010, 03:45 PM   #3
Exoskeletor
LQ Newbie
 
Registered: Jan 2010
Posts: 6

Original Poster
Rep: Reputation: 0
i have try to make this script:
echo "read columns"
read x1
read x2
gnuplot
#plot "mydata.dat" using $x1:$2
plot tail -10 "mydata.dat" using $x1:$2
set title "test"
set xlabel head -1 "mydata.dat $x1
set ylabel head -1 "mydata.dat $x2
set xrange [1.5:9.5]
set yrange [1.5:9.5]
set terminal svg
set output “myfile.svg”

but i get an gnuplot/n not found.. why?
also something tells me that plot tail -10 will not work, i have to find another way to read all the lines except the first
 
Old 01-03-2010, 04:22 PM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by Exoskeletor View Post
i have try to make this script:
echo "read columns"
read x1
read x2
gnuplot
#plot "mydata.dat" using $x1:$2
plot tail -10 "mydata.dat" using $x1:$2
set title "test"
set xlabel head -1 "mydata.dat $x1
set ylabel head -1 "mydata.dat $x2
set xrange [1.5:9.5]
set yrange [1.5:9.5]
set terminal svg
set output “myfile.svg”

but i get an gnuplot/n not found.. why?
also something tells me that plot tail -10 will not work, i have to find another way to read all the lines except the first
And why a program is not found - not necessarily 'gnuplot' ? I.e. have you heard of 'PATH' environment variable ?

And if the above is a shell script, why do you think the commands from the shell script will be fed into 'gnuplot' ?

AFAIR 'gnuplot' can read commands from file, so shy do you need the shell script in the first place ?
 
  


Reply

Tags
bash, gnuplot, script, shell


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
LXer: Create a graph of your system’s performance LXer Syndicated Linux News 0 12-11-2009 06:41 PM
LXer: Gplot simplifies gnuplot graph creation LXer Syndicated Linux News 0 02-27-2008 11:30 PM
Can not create filter graph - Morrowind MorbidConcept Linux - Games 0 07-28-2005 01:14 PM
gnuplot 4.0.0 ines Linux - Software 1 04-28-2005 02:26 PM
How to export graph as JPG file in Gnuplot ninja Linux - Software 1 05-30-2003 09:20 AM


All times are GMT -5. The time now is 01:16 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration