gnuplot:如何为每个像素绘制一个没有边距的二维数组元素

Hot*_*non 10 plot image gnuplot

我正在尝试使用 gnuplot 5.0 来绘制一个没有边距、边框或轴的二维数据数组......只是一个表示某些数据的二维图像(.png 或 .jpg)。我希望每个数组元素都对应于图像中的一个像素没有缩放/插值等,并且边缘没有额外的白色像素。

到目前为止,当我尝试将边距设置为 0 甚至使用pixels标志时,我仍然在图像的右侧和顶部边框上留下一行白色像素。

我怎样才能得到一个图像文件,其中包含数据数组的逐像素表示,而没有额外的东西?

gnuplot 脚本:

#!/usr/bin/gnuplot --persist

set terminal png size 400, 200

set size ratio -1
set lmargin at screen 0
set rmargin at screen 1
set tmargin at screen 0
set bmargin at screen 1

unset colorbox
unset tics
unset xtics
unset ytics
unset border
unset key

set output "pic.png"

plot "T.dat" binary array=400x200 format="%f" with image pixels notitle
Run Code Online (Sandbox Code Playgroud)

来自 Fortran 90 的示例数据:

program main
implicit none
integer, parameter :: nx = 400
integer, parameter :: ny = 200
real, dimension (:,:), allocatable :: T
allocate (T(nx,ny))

T(:,:)=0.500
T(2,2)=5.
T(nx-1,ny-1)=5.
T(2,ny-1)=5.
T(nx-1,2)=5.

open(3, file="T.dat", access="stream")
write(3) T(:,:)
close(3)

end program main
Run Code Online (Sandbox Code Playgroud)

额外的像素

Eth*_*han 5

一些 gnuplot 终端通过创建一个包含图像的单独 png 文件然后在结果图中链接到它来实现“带图像”。直接使用那个单独的 png 图像文件将避免任何页面布局、边距等问题。这里我使用画布终端。情节本身被扔掉了;我们保留的只是使用所需内容创建的 png 文件。

gnuplot> set term canvas name 'myplot'
Terminal type is now 'canvas'
Options are ' rounded size 600,400 enhanced fsize 10 lw 1 fontscale 1 standalone'
gnuplot> set output '/dev/null'
gnuplot> plot "T.dat" binary array=400x200 format="%f" with image 
   linking image 1 to external file myplot_image_01.png
gnuplot> quit

$identify myplot_image_01.png
myplot_image_01.png PNG 400x200 400x200+0+0 8-bit sRGB 348B 0.000u 0:00.000
Run Code Online (Sandbox Code Playgroud)