Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matrix 在热图中的gnuplot值上显示标签_Matrix_Gnuplot_Heatmap - Fatal编程技术网

Matrix 在热图中的gnuplot值上显示标签

Matrix 在热图中的gnuplot值上显示标签,matrix,gnuplot,heatmap,Matrix,Gnuplot,Heatmap,基于gnuplot的示例“以标签形式写入非零像素值的热图”,如下所示: 我有以下数据: 6 5 4 3 1 0 3 2 2 0 0 1 0 0 0 0 1 0 0 0 0 0 2 3 0 0 1 2 4 4 0 1 2 3 4 6 还有我的gnuplot: set terminal pngcairo enhanced font "arial,10" fontscale 1.0 size 500, 350 set output 'heatmaps.png' unset key set vi

基于gnuplot的示例“以标签形式写入非零像素值的热图”,如下所示:

我有以下数据:

6 5 4 3 1 0
3 2 2 0 0 1
0 0 0 0 1 0
0 0 0 0 2 3
0 0 1 2 4 4
0 1 2 3 4 6
还有我的gnuplot:

set terminal pngcairo enhanced font "arial,10" fontscale 1.0 size 500, 350 
set output 'heatmaps.png'

unset key
set view map
set xtics border in scale 0,0 mirror norotate  offset character 0, 0, 0 autojustify
set ytics border in scale 0,0 mirror norotate  offset character 0, 0, 0 autojustify
set ztics border in scale 0,0 nomirror norotate  offset character 0, 0, 0 autojustify
set nocbtics
set rtics axis in scale 0,0 nomirror norotate  offset character 0, 0, 0 autojustify
set xrange [ -0.500000 : 4.50000 ] noreverse nowriteback
set yrange [ -0.500000 : 4.50000 ] noreverse nowriteback
set cbrange [ 0.00000 : 5.00000 ] noreverse nowriteback
set palette rgbformulae -7, 2, -7
splot 'heatmap.txt' matrix using 1:2:3 with image, \
      'heatmap.txt' matrix using 1:2:($3 == 0 ? " " : sprintf("$3") ) with labels
这个脚本只是在每个标签中打印出“3”。你能帮我吗?谢谢

以及XTIC和Ytics的标签

 Tipe1 Tipe2 Tipe3 Tipe4 Tipe5
Failure1 6 2 0 0 1
Failure2 0 0 0 1 0
Failure3 0 0 0 2 3
Failure4 0 1 2 4 4
Failure5 1 2 3 4 6

再次感谢

我认为问题在于对sprintf函数的调用错误

sprintf(format,values)
您应该使用格式为(
%d
)的十进制数字和要显示的标签值(第三列
$3
)调用sprintf:

我将您的数据复制到一个文件(名为
data
)中,该示例运行良好:

plot 'data' matrix using 1:2:3 with image, '' matrix using 1:2:($3==0 ? " " : sprintf("%d",$3)) with labels  

希望有帮助

您几乎完全复制了链接的脚本,只更改了现在给您带来麻烦的部分。。。嗯;)谢谢你的建议@Christoph。是的,我会小心的:)没错,我错过了sprintf(“%d”,3美元)。还有一件事,如何更改Xtics和Ytics标签?6 5 4 3 1 0 3 2 2 0 0 1 0 0 0 0 1 0 0 0 0 0 2 3 0 0 1 2 4 4 0 1 2 3 4 6@indi60你们能更精确一点吗:你们说的xtic和Y标签是什么意思?我指的是X轴和Y轴上的标签。我发现这与我的问题有关。但这个例子不是使用矩阵。对此有什么建议吗?您可以通过以下方式设置预定义的TIC:SETXTICS(“Tipe1”0、“Tipe2”1、“Tipe3”2、“Tipe4”3、“Tipe5”4)@indi60实际上,中的解决方案与您发布的数据文件配合得很好。
plot 'data' matrix using 1:2:3 with image, '' matrix using 1:2:($3==0 ? " " : sprintf("%d",$3)) with labels