LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to create this graph in gnuplot (https://www.linuxquestions.org/questions/programming-9/how-to-create-this-graph-in-gnuplot-779553/)

Exoskeletor 01-03-2010 09:11 AM

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?

harry edwards 01-03-2010 09:59 AM

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.

Exoskeletor 01-03-2010 03:45 PM

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

Sergei Steshenko 01-03-2010 04:22 PM

Quote:

Originally Posted by Exoskeletor (Post 3812873)
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 ?


All times are GMT -5. The time now is 08:28 AM.