gnuplot矩阵或图:显示颜色和点值

问题描述 投票:7回答:2

我正在使用gnuplot来分析数据。

我经常使用调色板和矩阵。

但是每当我使用它时,精度总是有问题的。

如果我通过定义许多颜色来提高精度,则很难记住和阅读。

如果我减少颜色数量以清除比较,精度会降低。

所以我在考虑使用情节编号的矩阵。

如果我可以显示颜色和数字,则更容易查看和分析。

至少我想只显示数字,(只使用excel是一个选择,但我不想)

或显示不同颜色的数字。(颜色由点值决定)

如果您知道该怎么做,请告诉我。

如果您无法理解,请告诉我。

先感谢您,

matrix colors numbers gnuplot point
2个回答
7
投票

要绘制标签,只需使用with labels绘图样式。您可以使用任何字符串和字符串格式与sprintf设置标签:

reset
set autoscale fix
set palette defined (0 'white', 1 'green')
set tics scale 0
unset cbtics
set cblabel 'Score'
unset key
plot 'data.txt' matrix with image,\
     '' matrix using 1:2:(sprintf('%.2f', $3)) with labels font ',16'

pngcairo终端和gnuplot 4.6.3的结果是:

此示例的数据文件data.txt是:

0.22 0.13 0.54 0.83 0.08
0.98 0.57 0.52 0.24 0.66
0.23 0.68 0.24 0.89 0.76
0.89 0.78 0.69 0.78 0.10
0.24 0.77 0.27 0.28 0.69

0
投票

为了扩展上述答案:人们经常会发现,标签应该有不同的颜色才能被读取。要在深色背景上生成白色标签,在明亮的背景上生成黑色标签,请使用以下代码:

threshold = 123456
f = "..."
plot f matrix with image ,\
     '' matrix using 1:2:($3 > threshold ? sprintf('%1.2f', $3) : sprintf("")) with labels tc "white" ,\
     '' matrix using 1:2:($3 < threshold ? sprintf('%1.2f', $3) : sprintf("")) with labels tc "black"
© www.soinside.com 2019 - 2024. All rights reserved.