问题描述
我有一个dat文件test.dat,其中包含100行和100列。数据只是数字,0到5。现在,我想使用带图像的矩阵命令在Gnuplot中绘制此数据。命令在下面给出
set size square
set palette model RGB defined (0 "dark-pink",1 "yellow",2 "brown",3 "red",4 "green",5 "blue")
set cbrange [0:5]
unset colorBox
plot [1:100] [1:100] "test.dat" matrix with image
但是问题是在图中,数据以不同颜色的正方形显示。我希望这些数据将显示为不同颜色的圆圈。
解决方法
将其简单地绘制为matrix with points
和pointtype 7
。
代码:
### plot a matrix with points
reset session
N = 100
# create some test data
set print $Data
do for [i=1:N] {
Line = ''
do for [j=1:N] {
Line = Line.sprintf(" %d",int(rand(0)*6))
}
print Line
}
set print
set size square
set palette model RGB defined (0 "dark-pink",1 "yellow",2 "brown",3 "red",4 "green",5 "blue")
set cbrange [0:5]
unset colorbox
set tics out
set xrange[0:N+1]
set xtics 10
set mxtics 10
set yrange[0:N+1]
set ytics 10
set mytics 10
plot $Data u ($1+1):($2+1):3 matrix with p pt 7 ps 0.5 lc palette notitle
### end of code
结果: