问题
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
回答1:
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 imageset autoscale xfix set autoscale yfix set autoscale cbfix plot 'data.dat' matrix nonuniform with image notitle
pm3dset autoscale xfix set autoscale yfix set autoscale cbfix set pm3d map splot 'data.dat' matrix nonuniform notitle
来源:https://stackoverflow.com/questions/32458753/gnuplot-2d-plot-of-a-matrix-of-data