Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to plot 3D matrix CSV data in Gnuplot with splot using the first row and column as the x y coordinates?

Tags:

csv

gnuplot

How can I plot (a 3D plot) a matrix in Gnuplot having such data structure. I cannot find a way to use the first row and column as a x and y ticks (or to ignore them)

,5,6,7,8
1,-6.20,-6.35,-6.59,-6.02
2,-6.39,-6.52,-6.31,-6.00
3,-6.36,-6.48,-6.15,-5.90
4,-5.79,-5.91,-5.87,-5.46

Is the splot 'data.csv' matrix the correct parameter to use ?

like image 939
Jakub Czaplicki Avatar asked May 14 '10 14:05

Jakub Czaplicki


People also ask

Can gnuplot read csv file?

Not only is it very extensible, it is also reproducable. Give me a configfile and command over "do this, then this and then such and such" in Excel to get a consistent result. In this article I'll give tips for using gnuplot, which include: Parsing a CSV file.

How to plot data file in gnuplot?

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.

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 (p. ) for features common to the plot (p. ) command; only differences are discussed in detail here.

How to use gnuplot in cmd?

Running gnuplot is easy: from a command prompt on any system, type gnuplot. It is even possible to do this over a telnet or ssh connection, and preview the graphs in text mode! For best results, however, you should run gnuplot from within X Window, so that you can see better previews of your plots.


1 Answers

You can give using a format specification; here we need to tell the seperator ','. The following works for me:

splot 'data.csv' using 1:2:3 '%lf,%lf,%lf,%lf' with linespoints pt 6 ps 2 lw 3

except that the first line is ignored, which is probably right?

like image 124
osti Avatar answered Oct 02 '22 16:10

osti