我知道对于 4d 颜色图(3d 表面,颜色由第 4 个字段给出),我可以使用格式的数据文件
# X Y Z C
1 1 0 4
1 2 1 3
2 1 4 2
2 2 4 5
...
然后使用
set pm3d
splot "datafile.dat" u 1:2:3:4 with pm3d
另一方面,我知道如何制作一个简单的曲面图,其中 X 和 Y 值是隐式的,而 Z 值是矩阵格式:
#Z DATA ONLY
0 1
4 4
splot "datafile.dat" matrix
有没有办法使用这种矩阵格式制作 4d 彩色图?例如,从一个文件中获取 Z 数据并从另一个文件中获取相应的颜色数据,或者将 Z 值和颜色以矩阵格式合并到一个文件中?
最佳答案
如果我正确理解了这个问题,这似乎是可能的。请参阅下面的示例。
All we need to create such a plot is the
image
plot style, and of course the data have to be in a proper format. Suppose the following matrix which represents z-values of a measurement.0 1 2 3 4 3 2 1 0 0 1 2 3 4 3 2 1 0 0 1 2 3 4 3 2 1 0 0 1 2 3 4 3 2 1 0 0 1 2 3 4 3 2 1 0 0 1 2 3 4 3 2 1 0 0 1 2 3 4 3 2 1 0 0 1 2 3 4 3 2 1 0 0 1 2 3 4 3 2 1 0
In order to plot these values in different gray color tones, we specify the corresponding
palette
. In addition we apply the above mentionedimage
plot style and thematrix
format option. The result is shown in Fig. 2.set palette grey plot 'color_map.dat' matrix with image
# # Two ways of generating a 2D heat map from ascii data # set title "Heat Map generated from a file containing Z values only" unset key set tic scale 0 # Color runs from white to green set palette rgbformula -7,2,-7 set cbrange [0:5] set cblabel "Score" unset cbtics set xrange [-0.5:4.5] set yrange [-0.5:4.5] set view map splot '-' matrix with image 5 4 3 1 0 2 2 0 0 1 0 0 0 1 0 0 0 0 2 3 0 1 2 4 3 e e
关于graph - Gnuplot:使用矩阵格式的 4d 颜色图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6524206/