3d GnuPlot:热图的数据格式?

3d GnuPlot:热图的数据格式?,3d,gnuplot,heatmap,3d,Gnuplot,Heatmap,我想在GnuPlot做一个热图。以下是数据: 我用这个数据布局得到了它: …但我必须将Y轴的值四舍五入到最接近的5,以使它们适合网格的精确行 所以我想找出一个更三维的数据布局。我试过这样的方法: 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中的奇

我想在GnuPlot做一个热图。以下是数据:

我用这个数据布局得到了它:

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

所以我想找出一个更三维的数据布局。我试过这样的方法:

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://stackoverflow.com/questions/17154364/gnuplot-pm3d-plot-triangle-data?rq=1
# 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


更新:以下是我试图制作的图表:


我不完全清楚您的确切期望是什么…,但我会将打印样式
与boxxyerror一起使用(
帮助boxyError

代码:

### 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
### 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
结果:

### 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
### 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

谢谢你的建议,@theozh。我已经用一个我试图创建的图表的例子更新了原始帖子。有没有办法用您提供的数据格式创建该图表?@VikR请参阅修改后的答案。这回答了你的问题吗?然而,我会小心插值。在某些情况下,它可能给人的印象是有一些数据,尽管它可能只是一个插值人工制品,例如,在您的问题中,图中的垂直灰色“线”。