Plot 为pm3d贴图中矩阵的某些元素指定透明度
有两个数据文件,我需要使用pm3d贴图重叠它们的颜色贴图。我需要将透明度指定给最小的值,这样我就可以实际重叠两个绘图 第一个数据文件Plot 为pm3d贴图中矩阵的某些元素指定透明度,plot,gnuplot,Plot,Gnuplot,有两个数据文件,我需要使用pm3d贴图重叠它们的颜色贴图。我需要将透明度指定给最小的值,这样我就可以实际重叠两个绘图 第一个数据文件data1.dat包含: 1 1 1 1 1 1 1 1 1 1 1 1 1 30 1 1 45 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
data1.dat
包含:
1 1 1 1 1
1 1 1 1 1
1 1 1 30 1
1 45 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
第二个数据文件是:
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 80 1
1 1 1 20 1
以下是我使用gnuplot文件所做的尝试:
set terminal png
set output 'data_plot.png'
set pm3d map
set multiplot
stats "data1.dat" matrix name "A"
show variables A_
stats "data2.dat" matrix name "B"
show variables B_
splot for[i=0:4] 'data1.dat' matrix using (column(i)==A_min ? NaN :column(i)/A_max), for[i=0:4] 'data2.dat' matrix using (column(i)==B_min ? NaN :column(i)/B_max)
当我放置条件列(I)=A_min
时,它正在检查列号(显然)是否为A_min;是否有办法检查元素的值(访问元素)?
我需要将值为“1”的所有元素指定为透明。我无法使
pm3d
工作,可能是因为NaN值。是否可以选择使用rgbalpha
(help rgbalpha
)
命令使用rgbalpha打印需要6列:x、y、r、g、b、alpha。这意味着我们需要坐标,并且我们必须将矩阵值映射到颜色值。我们从中吸取了一些想法。引用一个:
当使用矩阵时,gnuplot在内部生成三列:第一列是矩阵列,第二列是矩阵行,第三列包含实际的矩阵数据值
对于颜色的计算,使用默认映射(在阅读帮助RGB公式
之后,显示调色板RGB公式
)。颜色值r、g和b应介于0和255之间。对矩阵值进行映射,以使每个文件中的最高值显示为黄色。透明度函数a(x)为参数1返回0(完全透明),否则返回255(不透明)
结果是:
请注意,打印样式“rgbalpha”和“pm3d”对坐标的处理方式不同。这可能需要对xrange和yrange进行一些调整,或者使用1:2:…
对进行一些转换,如使用($1+0.5):($2+0.5):…
,具体取决于您的需要
set terminal pngcairo
set output 'data_plot.png'
stats "data1.dat" matrix name "A"
show variables A_
stats "data2.dat" matrix name "B"
show variables B_
set nokey
r(x) = 255*sqrt(x) # rgbformulae 7
g(x) = 255*x**3 # rgbformulae 5
b(x) = 255*(0.5+0.5*sin(2.0*pi*x)) # rgbformulae 15
a(x) = (x==1) ? 0 : 255 # fully transparent or opaque
plot 'data1.dat' matrix using 1:2:(r($3/A_max)):(g($3/A_max)):(b($3/A_max)):(a($3)) with rgbalpha ,\
'data2.dat' matrix using 1:2:(r($3/B_max)):(g($3/B_max)):(b($3/B_max)):(a($3)) with rgbalpha