gnuplot matrix or plot : display both color and point value

十年热恋 提交于 2019-12-04 20:58:31

问题


I'm using gnuplot to analysis data.

And I frequently use palette and matrix.

However whenever I use that, precision is always problem.

If I increase precision by define many color, it is difficult to remember and to read.

If I decrease number of color to clear comparison, precision become decrease.

So I'm thinking matrix with plot number.

If I can display both color and number, it will be more easy to see and analysis.

At least I want display only number,(Just use excel is a one choice but I don't want to)

or display number with different color.(color determined by point value)

If you know the way to do, please let me know.

If you can't understand, please tell me.

Thank you in advance,


回答1:


To plot the labels, just use the with labels plotting style. You can use any string and string formatting e.g. with sprintf to set the label:

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'

The result with the pngcairo terminal and gnuplot 4.6.3 is:

The data file data.txt for this example is:

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



回答2:


To expand the above answer: One often finds the case, that the labels should have different colors in order to be readable. To produce white labels on a dark background and black labels on bright background I use the following code:

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"


来源:https://stackoverflow.com/questions/18813394/gnuplot-matrix-or-plot-display-both-color-and-point-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!