gnuplot: 2D plot of a matrix of data

牧云@^-^@ 提交于 2019-12-21 04:14:39

问题


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.

  1. with image

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

  1. pm3d

    set 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!