用图像和具有透明度的数据文件矩阵图组合图
Compose a plot with an image and a plot of a datafile matrix with transparency
我正在尝试使用城市地图图像制作地块
并叠加这个
与该位置的街道相匹配,并产生这样的图形
通过 GIMP 制作。
我想用 Gnuplot 制作一个类似于上面的图,将两个图像叠加在一起,地图在后面,pher.txt 数据在前面。
我可以使用这个脚本来绘制地图:
set encoding iso_8859_1
set term postscript eps enhanced color size 5in,5in
set output 'image.eps'
unset key; unset tics; unset border
set size ratio -1
set size square
set lmargin screen 0
set bmargin screen 0
set rmargin screen 1
set tmargin screen 1
plot 'ghent0.png' binary filetype=png with rgbimage
借用 Gnuplotting 的 link 来绘制地图。
要绘制热图,我使用以下代码:
set terminal pngcairo nobackground #size 800,800
# set encoding iso_8859_1
# set term postscript eps enhanced color size 5in,5in
set output 'foo.png'
set size square
unset xtics
unset ytics
val = 0
set autoscale xfix
set autoscale yfix
set cbrange [0:9]
set yrange [:] reverse
# plot 'pher.txt' matrix using ( == val ? NaN : ) with image notitle
plot 'pher.txt' matrix with image notitle
为了使黑色透明,我尝试 plot 'pher.txt' matrix using ( == val ? NaN : ) with image notitle
从“Transparency for specific values in matrix ...”中借用,它告诉 Gnuplot 将 NaN 值放在 pher.txt
矩阵中有 0 的位置数据文件。但是,它不起作用。
此外,应调整两个图层(图像地图和黑色透明的热图)的大小,以便热图线与地图的街道相匹配。
注:地图图片和文件pher.txt
在这个linkMapDatafile
此致
当您 plot ... matrix with image
时,图像值位于第三列,而不是第一列。这是一个解决方案,它在 (x,y) 坐标系中绘制地图,在 (x2,y2) 坐标系中绘制您的数据。这样,您只需设置 x2range
和 y2range
:
即可相对于前者重新缩放后者
set size square
set xtics nomirror
set ytics nomirror
set x2tic
set y2tic
set x2range [-1:200]
set y2range [-1:204] reverse
set autoscale noextend
set cbrange [0:9]
plot 'ghent0.jpg' binary filetype=jpg with rgbimage, \
'pher.txt' matrix using 1:2:( == 0 ? NaN : ) axes x2y2 with image notitle
我正在尝试使用城市地图图像制作地块
并叠加这个
与该位置的街道相匹配,并产生这样的图形
通过 GIMP 制作。
我想用 Gnuplot 制作一个类似于上面的图,将两个图像叠加在一起,地图在后面,pher.txt 数据在前面。
我可以使用这个脚本来绘制地图:
set encoding iso_8859_1
set term postscript eps enhanced color size 5in,5in
set output 'image.eps'
unset key; unset tics; unset border
set size ratio -1
set size square
set lmargin screen 0
set bmargin screen 0
set rmargin screen 1
set tmargin screen 1
plot 'ghent0.png' binary filetype=png with rgbimage
借用 Gnuplotting 的 link 来绘制地图。
要绘制热图,我使用以下代码:
set terminal pngcairo nobackground #size 800,800
# set encoding iso_8859_1
# set term postscript eps enhanced color size 5in,5in
set output 'foo.png'
set size square
unset xtics
unset ytics
val = 0
set autoscale xfix
set autoscale yfix
set cbrange [0:9]
set yrange [:] reverse
# plot 'pher.txt' matrix using ( == val ? NaN : ) with image notitle
plot 'pher.txt' matrix with image notitle
为了使黑色透明,我尝试 plot 'pher.txt' matrix using ( == val ? NaN : ) with image notitle
从“Transparency for specific values in matrix ...”中借用,它告诉 Gnuplot 将 NaN 值放在 pher.txt
矩阵中有 0 的位置数据文件。但是,它不起作用。
此外,应调整两个图层(图像地图和黑色透明的热图)的大小,以便热图线与地图的街道相匹配。
注:地图图片和文件pher.txt
在这个linkMapDatafile
此致
当您 plot ... matrix with image
时,图像值位于第三列,而不是第一列。这是一个解决方案,它在 (x,y) 坐标系中绘制地图,在 (x2,y2) 坐标系中绘制您的数据。这样,您只需设置 x2range
和 y2range
:
set size square
set xtics nomirror
set ytics nomirror
set x2tic
set y2tic
set x2range [-1:200]
set y2range [-1:204] reverse
set autoscale noextend
set cbrange [0:9]
plot 'ghent0.jpg' binary filetype=jpg with rgbimage, \
'pher.txt' matrix using 1:2:( == 0 ? NaN : ) axes x2y2 with image notitle