Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gnuplot: How to plot each line of a data file as Y and incremental X

Tags:

gnuplot

I have a data file containing 30 columns and N rows. Each rows correspond to 30 values of function f(x) for x={1,...,30}. The data file has following pattern:

#<index> f(1) f(2) ... f(30)
1 7.221 5.302 ... -1.031
2 4.527 3.193 ... 0.410
...
N 6.386 1.321 ... -0.386

gnuplot interprets first column as X and the second one as Y. But, what I want is to plot each line in a separated output file without transposing this data file. For example, for the first line, the desired output would be what gnuplot gets with this input file:

# X Y
1 7.221
2 5.302
...
30 -1.031
like image 436
cartoonist Avatar asked Dec 27 '11 15:12

cartoonist


People also ask

Which of the following command will used to plot a vertical line in gnuplot?

to draw a vertical line The range of t is controlled by the command set trange . In this case the vertical line is draw at x=3.

How use gnuplot data file?

To plot functions simply type: plot [function] at the gnuplot> prompt. Discrete data contained in a file can be displayed by specifying the name of the data file (enclosed in quotes) on the plot or splot command line. Data files should have the data arranged in columns of numbers.

How the plot generated by gnuplot may be saved in a file?

There are two ways to save your work in gnuplot: you can save the gnuplot commands used to generate a plot, so that you can regenerate the plot at a later time. Or you can export the graph to a file in a standard graphics file format, so that you can print it or include it in web pages, documents, or presentations.

What is gnuplot Splot?

splot is the command for drawing 3-d plots (well, actually projections on a 2-d surface, but you knew that). It can create a plot from functions or a data file in a manner very similar to the plot command. See plot for features common to the plot command; only differences are discussed in detail here.


2 Answers

I found a solution:

plot "data.dat" matrix every 1::1 with linespoint
  • matix indicates data file type by which the input file interpreted as matrix.
  • every 1::1 skip the first column
like image 134
cartoonist Avatar answered Sep 28 '22 08:09

cartoonist


UPDATED based on @Christoph's comment:

plot for [i=2:30] 'data.dat' using (i-1):(column(i)) with linespoint
like image 33
Amit Sharma Avatar answered Sep 28 '22 09:09

Amit Sharma