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
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.
The command set multiplot places gnuplot in the multiplot mode, in which several plots are placed on the same page, window, or screen.
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.
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).
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.
with image
set autoscale xfix
set autoscale yfix
set autoscale cbfix
plot 'data.dat' matrix nonuniform with image notitle
pm3d
set autoscale xfix
set autoscale yfix
set autoscale cbfix
set pm3d map
splot 'data.dat' matrix nonuniform notitle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With