Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
543 views
in Technique[技术] by (71.8m points)

gnuplot : plotting data from multiple input files in a single graph

I am trying to plot a graph using gnuplot. I have six text files. Each text file contains two columns. The first column represents time in seconds (a floating point number). The second one is a sequence number. I want to plot the graph of time vs. sequence number in a single graph for all six files. I am using this file to do that.

set terminal png
set output 'akamai.png'

set xdata time
set timefmt "%S"
set xlabel "time"

set autoscale

set ylabel "highest seq number"
set format y "%s"

set title "seq number over time"
set key reverse Left outside
set grid

set style data linespoints

plot "print_1012720" using 1:2 title "Flow 1", 
plot "print_1058167" using 1:2 title "Flow 2", 
plot "print_193548"  using 1:2 title "Flow 3",  
plot "print_401125"  using 1:2 title "Flow 4", 
plot "print_401275"  using 1:2 title "Flow 5", 
plot "print_401276"  using 1:2 title "Flow 6"

Where my files are:

  • print_1012720
  • print_1058167
  • print_193548
  • print_401125
  • print_401275
  • print_401276

It is giving a strange error as below:

"plot.plt", line 24: undefined variable: plot

Am I doing something wrong? Is it possible to plot the input data from different files in the same graph?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You're so close!

Change

plot "print_1012720" using 1:2 title "Flow 1", 
plot "print_1058167" using 1:2 title "Flow 2", 
plot "print_193548"  using 1:2 title "Flow 3",  
plot "print_401125"  using 1:2 title "Flow 4", 
plot "print_401275"  using 1:2 title "Flow 5", 
plot "print_401276"  using 1:2 title "Flow 6"

to

plot "print_1012720" using 1:2 title "Flow 1", 
     "print_1058167" using 1:2 title "Flow 2", 
     "print_193548"  using 1:2 title "Flow 3",  
     "print_401125"  using 1:2 title "Flow 4", 
     "print_401275"  using 1:2 title "Flow 5", 
     "print_401276"  using 1:2 title "Flow 6"

The error arises because gnuplot is trying to interpret the word "plot" as the filename to plot, but you haven't assigned any strings to a variable named "plot" (which is good – that would be super confusing).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...