1

Is it possible with gnuplot to print the data that I plotted next to the graph?

If I have a text file input.txt:

#x y
 1 2
 2 5
 3 6
 4 7

And I do plot 'input.txt' I'd like to have it plotted as usual and next to the plot I'd like to have the table printed. Is this possible?

Note: I'm on Windows and I'd like to format the output.

Foo Bar
  • 1,581
  • 4
  • 22
  • 42
  • How would you like to format the output? A minimal version of your script (including terminal settings) would be helpful. – andyras Mar 06 '14 at 15:13
  • I don't yet have a script (yet). I'd like to create plots like these: http://www.w-hanisch.de/assets/images/Los_Angeles.USA.jpg (the plot is no problem, I can do that, but getting the raw input formatted as a nice table next to the plot like in the picture is the problem because I don't know any commands that do that). Btw: the plot in the link is from a commercial program that can do only pixel pictures, I'd like to use gnuplot to create SVG to have a free and scaling alternative. – Foo Bar Mar 06 '14 at 15:51
  • That would probably be /possible/ but complicated, involving multiple parsing steps with external utils, multiple labels and drawing lines manually. I think it would not be worth the effort, and I suggest composing the figure as a PowerPoint slide and exporting it as a .png. – andyras Mar 06 '14 at 16:55

1 Answers1

0

Sure you can. The simplest way to do this in gnuplot is read in the file by calling an external command (cat on *nix, not sure on Windows) and storing the output as a variable, then setting a label on the graph. Here is how I do it:

set rmargin 8

datas = system('cat data.dat')
print datas

set label datas at graph 1.1,0.7

plot 'data.dat' notitle

This puts the data file off to the side, in place of a key.

enter image description here

andyras
  • 14,972
  • 6
  • 53
  • 72
  • Ah, I was hoping to be able to format the output somehow... And I'm on Windows. I don't know a cat command equivalent... – Foo Bar Mar 06 '14 at 13:49
  • And this question is already answered [here](http://stackoverflow.com/questions/206114/batch-files-how-to-read-a-file). Common case, looping through file entries using `FOR`. – Kamiccolo Mar 06 '14 at 16:08