Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gnuplot: 2D plot of a matrix of data

Tags:

gnuplot

How can I plot (a 2D plot) a matrix in Gnuplot having such data structure, using the first row and column as a x and y ticks (the first number of the first row is the number of columns) and represent the rest of the values by a colour mapping so it can be seen on a 2D plane ?

4 0.5 0.6 0.7 0.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
like image 266
Jack Avatar asked Sep 08 '15 13:09

Jack


People also ask

How use gnuplot to plot data from a 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.

What is Multiplot gnuplot?

The command set multiplot places gnuplot in the multiplot mode, in which several plots are placed on the same page, window, or screen.

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.

Does gnuplot support multiple Y axes on a single plot?

5.9 Does gnuplot support multiple y-axes on a single plot? Yes. 2D plots can have separate x axes at the bottom (x1) and top (x2), and separate y axes at the left (y1) and right (y2).


1 Answers

You can plot this data format using matrix nonuniform.

To get a heatmap you can plot either with image (regular grid, no interpolation, one quadrangle for each data point), or splot with pm3d (supports also irregular grids and interpolation, plots one quadrangle for four neighboring data points.

  1. with image

    set autoscale xfix
    set autoscale yfix
    set autoscale cbfix
    plot 'data.dat' matrix nonuniform with image notitle
    

enter image description here

  1. pm3d

    set autoscale xfix
    set autoscale yfix
    set autoscale cbfix
    set pm3d map
    splot 'data.dat' matrix nonuniform notitle
    

enter image description here

like image 175
Christoph Avatar answered Oct 20 '22 23:10

Christoph