Gnuplot 脚本生成黑色背景图片而不是预期图片

Gnuplot script produces picture with black background instead of expected picture

这是我使用的 gnuplot 脚本的一部分:

set terminal png transparent
#plot "back.png" binary filetype=png w rgbimage
filename = "/MyData/MyRadio/ND/Server/GNUPlot/anim/map_".i.".dat"
plotfile = "/MyData/MyRadio/ND/Server/GNUPlot/anim/graph_".i.".png"
set output plotfile
set ylabel "Latitude"
set xlabel "Longitude"
set cbrange [0.5e9:3e9]
set palette defined (0.5 "blue", 1 "green",1.5 "yellow", 2.1 "orange", 3 "red")
plot 'back.png' binary filetype=png center=(0,0) with rgbimage notitle, \
filename using  2:3:4 title columnheader(1) with points pt 7 ps 2 palette
set output
i=i+1
if (i <= n) reread

但是,它生成的 .png 文件具有黑色背景而不是图片:

.

问题出在颜色条上,出现 [0.5e9:3e9]。 并且 RGBimage 上升到 256(如您在上面评论中发布的 link 中所见)。

试试这样的东西:

c_min=0.5e9
c_max=3e9

set cbrange [c_min:c_max]
plot \
'test.png' binary filetype=png center=(0,0) u 1:2:(c_min+/256.*(c_max-c_min)) with rgbimage notitle, \
'test.txt' with points pt 7 ps 2 palette

可能是 gnuplot 中的一个错误,因为 rgbimages 不应该受到颜色条的影响(因为它们使用了正确的颜色条)。

否则我会建议使用 multiplot 作为完成 HERE

在重要谈判的情况下,如果您需要创建动画 .gif 像这样 out.gif 在背景上使用固定图像,您可以使用此 code.plt:

reset
set term png transparent truecolor size 930, 880
set output "outpit".i.".png"
set multiplot
set origin 0,0
filename = "in_".i.".dat"
print filename." ".plotfile
unset tics
unset border
set lmargin at screen 0.08
set rmargin at screen 0.85
set bmargin at screen 0.1
set tmargin at screen 0.98
plot "background.png" binary filetype=png center=(0,0) with rgbimage
set tics
set border
set xrange [40.1:63.11]
set yrange [49.28:62.44]
set cbrange [0.5e9:3e9]
set palette defined (0.5 "blue", 1 "green",1.5 "yellow", 2.1 "orange", 3 "red")
plot filename using  2:3:4 title columnheader(1) with points pt 7 ps 3 palette
unset multiplot
unset output
i=i+1
if (i <= n) reread

不要忘记设置 i(开始)和 n(停止)。 例如,在 .gif 动画 .gif 图像 ffmpg 中收集所有 .png 之后。