GnuPlot:热图的数据格式?

GnuPlot: Data Format for Heat Map?

我正在尝试在 GnuPlot 中制作热图。这是数据:

我使用了这个数据布局:

...但我必须将 Y 轴值四舍五入到最接近的 5 以使它们适合网格的确切行。

所以我想找出一个更 3D 的数据布局。我试过这样的事情:

X    Y    Z
1   69  3.9

2   44  5.2

3   39  2.6

4   51  5.1

5   50  2.2

6   47  2.5

7   52  2.1

8   52  2.6

9   52  4.0

...但我收到“LU-DECOMP 中的奇异矩阵”错误。

我尝试在数据文件中为每个 Z 值做多行,但我不知道为空的 X 和 Y 位置放什么。

像这样布置数据文件的正确方法是什么?

为了完整起见,这是我的命令文件:

unset surface
unset key
set view map
set pm3d
set palette defined (0 'black', 1 'gray40', 2 'dark-green', 3 '#fee000', 4 '#fc7a00', 5 '#ff0000')
set cbrange [0:5]
set output 'temp.jpg'

set term jpeg size 900, 900 enhanced font '/Library/Fonts/Arial.ttf' 12  #000000 Effffff
set dgrid3d 400,400 splines
set size square
set xtics("" 1, "X Label 1" 2, "X Label 2" 3, "X Label 3" 4, "X Label 4" 5, "X Label 5" 6, "X Label 6" 7, "X Label 7" 8, "X Label 8" 9, "X Label 9" 10)
unset label
unset title
set title '{/=18 Title}'  offset 0, .5
set ylabel '{/=18 Y Label}'  offset -1.6, 0
set xlabel '{/=18 X Label}'  offset 0,-3.0
set xtics out nomirror
set ytics out nomirror
set ytics("25" 0, "30" 1, "35" 2, "40" 3, "45" 4, "50" 5, "55" 6, "60" 7, "65" 8, "70" 9, "75" 10, "" 11)
set y2tics("25" 0, "30" 1, "35" 2, "40" 3, "45" 4, "50" 5, "55" 6, "60" 7, "65" 8, "70" 9, "75" 10, "" 11)

set xrange [0:11] 
set yrange [0:11]
unset colorbox 

set link x2; set link y2

splot [1:] '/gnuplot_data_test_v400.txt' matrix

replot


# http://hirophysics.com/gnuplot/gnuplot10.html
# 
# https://askubuntu.com/questions/900501/i-cant-splot-with-pm3d-map-my-data-file-gnuplot
# http://lowrank.net/gnuplot/datafile-e.html#3dim
# http://psy.swansea.ac.uk/staff/carter/gnuplot/gnuplot_3d.htm


更新: 这是我正在尝试制作的图表类型:

我不太清楚你的确切期望是什么...,但我会使用绘图样式 with boxxyerror(检查 help boxxyerror)。

代码:

### heatmap with boxxyerror
reset session

# X    Y    Z
$Data <<EOD
1   69  3.9
2   44  5.2
3   39  2.6
4   51  5.1
5   50  2.2
6   47  2.5
7   52  2.1
8   52  2.6
9   52  4.0
EOD

myXLabels = '"Label A" "Label B" "Label C" "Label D" "Label E" "Label F" "Label G" "Label H" "Label I"'
myXtic(col) = word(myXLabels,int(column(col)))
BoxWidth = 1
BoxHeight = 1
xLow(col)  = column(col)-BoxWidth/2.
xHigh(col) = column(col)+BoxWidth/2.
yLow(col)  = column(col)-BoxHeight/2.
yHigh(col) = column(col)+BoxHeight/2.

set style fill solid 1.0
plot $Data u 1:2:(xLow(1)):(xHigh(1)):(yLow(2)):(yHigh(2)):3:xtic(myXtic(1)) w boxxy fc palette notitle
### end of code

结果:

加法:

在不知道您的应用程序详细信息的情况下,以下内容可能是一个起点。在 z=0 的角上添加一些点。您可能想“玩”行 set dgrid3d 200,200 gauss kdensity 1.5.

中的值

代码:

### heatmap with interpolation
reset session

# X    Y    Z
$Data <<EOD
1   69  3.9
2   44  5.2
3   39  2.6
4   51  5.1
5   50  2.2
6   47  2.5
7   52  2.1
8   52  2.6
9   52  4.0
EOD

# add some points in the corners with z=0
set print $Data append
do for [x=0:10:10] {
    do for [y=35:70:35] {
        print sprintf("%g %g %g",x,y,0)
    }
}
set print

set view map
set palette defined (0 'black', 1 'gray40', 2 'dark-green', 3 '#fee000', 4 '#fc7a00', 5 '#ff0000')
set dgrid3d 200,200 gauss kdensity 1.5
unset key
set tics out

splot $Data u 1:2:3 w pm3d
### end of code

结果: