我正在尝试使用gnuplot生成热图,但是对于热图中的每个条目都有两个不同的信息。虽然热图将值显示为颜色,但我希望热图中的每个块也显示文本信息。
以下脚本创建了我所想的一半:
set term postscript eps color solid
set output '1.eps'
set title "Heat Map generated from a file containing Z values only"
unset key
set tic scale 0
set border linewidth 2
set palette rgbformula -7,2,-3
unset cbtics
unset colorbox
unset xtics
set x2tics ("A" 0, "B" 1, "C" 2, "D" 3, "E" 4)
set ytics ("N0" 0, "N1" 1, "N2" 2, "N3" 3, "N4" 4)
set style line 102 lc rgb'#101010' lt 0 lw 4
set grid front ls 102
set datafile separator ","
plot 'matrix.txt' matrix with image, "" matrix using 1:2:(sprintf('%.2f', $3)) with labels font ',12' offset 0,1.2
set datafile separator
数据文件matrix.txt包含以下信息:
7 B, 5 B, 4 D, 3 B, 1 D
2 B, 2 A, 2 D, 0 C, 0 A
3 B, 0 A, 0 E, 0 E, 1 C
4 C, 0 A, 0 B, 0 E, 2 C
5 D, 0 A, 1 A, 2 A, 4 A
下图可以从脚本生成:
我希望能够在每个条目中添加文本信息作为矩阵条目的第二部分(在网格线下方)。
我想知道你们是否对如何提出任何建议。谢谢
似乎您不能同时使用stringcolumn
(或strcol
)matrix
来获取包含在各个矩阵元素中的完整字符串。解决方法是,必须遍历所有列,并使用标签分别绘制每个列:
set title "Heat Map generated from a file containing Z values only"
unset key
set tic scale 0
set border linewidth 2
set palette rgbformula -7,2,-3
unset cbtics
unset colorbox
unset xtics
set x2tics ("A" 0, "B" 1, "C" 2, "D" 3, "E" 4)
set ytics ("N0" 0, "N1" 1, "N2" 2, "N3" 3, "N4" 4)
set style line 102 lc rgb'#101010' lt 0 lw 4
set grid front ls 102
set datafile separator ","
plot 'matrix.txt' matrix with image, \
for [i=1:5] '' using 0:(i-1):i with labels font ',12' offset 0,1.2
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句