1

I am new to GNUPLOT and, I have encountered a problem which I do not know how to deal with. Any help from your side will be appreciated. The problem is:

I have two files, say "A.dat" and "B. dat". Both are multidimensional array data. To be exact,

A.dat has 1000 rows and 100 columns. let row index be i from 1 to 1000, column index be k from 1 to 100.

B.dat has 1000 rows and 100 columns. let row index be i from 1 to 1000, column index be k from 1 to 100

I want to have a two-dimensional plot, which has a total of k curves in it, 100 curves!

So, a given k-curve is drawn the coordinate axes, whose X coordinates are from A data and ,Y coordinates are from B data respectively.

So a k= 50 curve should be formed, whose x values are the respective 50th column values of A.dat and, y values the respective 50th column values of B.dat. Also since for a total of 100 curves, I will like to have some sort of colour scale, like, k=1 be violet, k =100 be red.

Any idea on how to implement this?

james
  • 13
  • 3

1 Answers1

0

In order to plot your data, you must have x and y-values in a single file. The easiest way to get this is using e.g. the command line tool paste (or, if you are on Windows, use the paste.py script mentioned in Get ratio from 2 files in gnuplot). Then you can plot them with

plot for [k=1:100] '< paste A.dat B.dat' using k:(column(k+100))

To get coloured lines you may define a custom color palette and use this with

set palette defined (0 'red', 1 'dark-violet')
plot for [k=1:100] '< paste A.dat B.dat' using k:(column(k+100)):(k) linecolor palette with lines notitle
Community
  • 1
  • 1
Christoph
  • 47,569
  • 8
  • 87
  • 187
  • many thanks for your trick. It worked, but not satisfactorily. I am attaching the outcome here. http://postimg.org/image/f6cll0ayr/ How to get a better spectrum and also it seems picture is overpopulated with linetype symbols. I do not want them. I prefer just smooth curves and a colour palette showing the magnitude of k. – james May 11 '15 at 17:57
  • I updated the answer, use `with lines` to get lines, `notitle` to omit the titles, and `linecolor palette` and a third column in the `using` statement to have the value of `k` on the colorbar. – Christoph May 11 '15 at 18:23
  • For some reason, the data plotted with MatLaB looks fine, but GNUPLOT is not doing good. also it consumes much time. – james May 11 '15 at 20:36
  • The performance can be improved by generating a temporary file with `system('paste A.dat B.dat > C.dat')` and then plotting the file `C.dat` otherwise, the `paste` operation is done 100 times. About the "looks fine" I cannot say anything without concrete data files – Christoph May 11 '15 at 20:43
  • I have always been a fan of GNUPLOT. to me the plots generated by gnuplot look cleaner. If you wish I can send the data files to you and the plots generated by Matlab and gnuplot. However let me try it myself first. And thanks again. – james May 11 '15 at 20:49
  • Yes, go ahead and let me know. – Christoph May 11 '15 at 21:00
  • How do I send the data files to you. Do you have Matlab for reference? – james May 14 '15 at 09:37