I wanted to plot a graph with respect to values from a file.
I'm doing it with Excel 2007, but I want to create the chart in script itself.
I searched in internet for GNUPLOt. But I couldn't understand anything.
Here is my situation. I have a file having values separated by "|".
First column is time, Second is node1,node2 and so on. I need to plot a line graph with column1 and 2, column1 and 3 .......... resulting in 13 graphical outputs which I want to store in a file.
I tried to generate a graph but I am not successful.
That's weird... Which system and what version of gnuplot are You using? Are You working on Your local computer or somewhere remote? How did You install gnuplot - repositories or compiling on Your own?
I am getting below output after setting the terminal to postscript.
gnuplot> plot sin(x)
%%Page: 2 2
gnudict begin
gsave
50 50 translate
0.100 0.100 scale
90 rotate
0 -5040 translate
0 setgray
newpath
(Helvetica) findfont 140 scalefont setfont
1.000 UL
LTb
714 420 M
63 0 V
6185 0 R
-63 0 V
630 420 M
gsave 0 setgray
(-2) Rshow
grestore
1.000 UL
LTb
714 977 M
63 0 V
6185 0 R
-63 0 V
630 977 M
gsave 0 setgray
(-1.5) Rshow
grestore
1.000 UL
LTb
714 1533 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
(-1) Rshow
grestore
1.000 UL
LTb
714 2090 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
(-0.5) Rshow
grestore
1.000 UL
LTb
714 2646 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
( 0) Rshow
grestore
1.000 UL
LTb
714 3203 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
( 0.5) Rshow
grestore
1.000 UL
LTb
714 3759 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
( 1) Rshow
grestore
1.000 UL
LTb
714 4316 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
( 1.5) Rshow
grestore
1.000 UL
LTb
714 4872 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
( 2) Rshow
grestore
1.000 UL
LTb
714 420 M
0 63 V
0 4389 R
0 -63 V
714 280 M
gsave 0 setgray
( 0) Cshow
grestore
1.000 UL
LTb
1964 420 M
0 63 V
0 4389 R
0 -63 V
0 -4529 R
gsave 0 setgray
( 1) Cshow
grestore
1.000 UL
LTb
3213 420 M
0 63 V
0 4389 R
0 -63 V
0 -4529 R
gsave 0 setgray
( 2) Cshow
grestore
1.000 UL
LTb
4463 420 M
0 63 V
0 4389 R
0 -63 V
0 -4529 R
gsave 0 setgray
( 3) Cshow
grestore
1.000 UL
LTb
5712 420 M
0 63 V
0 4389 R
0 -63 V
0 -4529 R
gsave 0 setgray
( 4) Cshow
grestore
1.000 UL
LTb
6962 420 M
0 63 V
0 4389 R
0 -63 V
0 -4529 R
gsave 0 setgray
( 5) Cshow
grestore
1.000 UL
LTb
1.000 UL
LTb
714 420 M
6248 0 V
0 4452 V
-6248 0 V
714 420 L
LTb
140 2646 M
gsave 0 setgray
currentpoint gsave translate 90 rotate 0 0 M
(Y-AXIS) Cshow
grestore
grestore
LTb
3838 70 M
gsave 0 setgray
(X-AXIS) Cshow
grestore
1.000 UP
1.000 UL
LT0
LTb
6311 4739 M
gsave 0 setgray
(sin\(x\)) Rshow
grestore
LT0
6395 4739 M
399 0 V
714 2646 M
63 56 V
63 56 V
63 56 V
63 55 V
64 55 V
63 54 V
63 53 V
63 53 V
63 51 V
63 50 V
63 48 V
63 47 V
63 45 V
64 44 V
63 42 V
63 40 V
63 37 V
63 36 V
63 34 V
63 31 V
63 28 V
63 26 V
64 24 V
63 21 V
63 19 V
63 15 V
63 13 V
63 10 V
63 8 V
63 4 V
63 2 V
64 -1 V
63 -4 V
63 -7 V
63 -10 V
63 -12 V
63 -15 V
63 -18 V
63 -20 V
63 -24 V
64 -25 V
63 -28 V
63 -31 V
63 -33 V
63 -35 V
63 -37 V
63 -40 V
63 -41 V
63 -44 V
64 -45 V
63 -46 V
63 -48 V
63 -50 V
63 -51 V
63 -52 V
63 -53 V
63 -54 V
63 -54 V
64 -56 V
63 -55 V
63 -56 V
63 -57 V
63 -56 V
63 -56 V
63 -56 V
63 -55 V
63 -55 V
64 -54 V
63 -54 V
63 -52 V
63 -51 V
63 -50 V
63 -49 V
63 -48 V
63 -45 V
63 -44 V
64 -42 V
63 -41 V
63 -38 V
63 -36 V
63 -34 V
63 -31 V
63 -30 V
63 -26 V
63 -25 V
64 -21 V
63 -19 V
63 -16 V
63 -14 V
63 -11 V
63 -7 V
63 -6 V
63 -2 V
63 1 V
64 3 V
63 6 V
63 9 V
63 12 V
63 15 V
1.000 UL
LTb
714 420 M
6248 0 V
0 4452 V
-6248 0 V
714 420 L
1.000 UP
stroke
grestore
end
showpage
gnuplot>
Now I have set output to a file. But its not in Graphical format.
---------- Post updated at 04:48 PM ---------- Previous update was at 04:46 PM ----------
I am using gnuplot version 4.0 ........ on a remote system.
Ok, so You have to set output terminal different. Try this:
set terminal png # gnuplot recommends setting terminal before output
set output "output.png" # The output filename; to be set after setting
# terminal
plot sin(x)
First, you create a Gnuplot template (template.gp)
set datafile separator "|"
set xdata time
set timefmt '%H:%M:%S'
set terminal png
set output 'column-@COLUMN@.png'
set yrange [0:]
set title 'column @COLUMN@'
set grid
plot 'SCP_CAPS_24012012.txt' using 1:@COLUMN@ title 'column @COLUMN@' with linespoints
Now you can dynamically substitute @COLUMN@ with the actual column number and create all the graphs in a loop
for i in 2 3 4 5 6 7 8
do
sed "s/@COLUMN@/$i/g" template.gp | gnuplot - > /dev/null 2>&1
done
BTW, you can also plot all the columns in one single PNG file