【问题标题】:gnuplot: plot image without white bordergnuplot:绘制没有白色边框的图像
【发布时间】:2015-06-09 13:49:10
【问题描述】:

我想使用 gnuplot 绘制图像数据,没有任何边框、抽动等。只是图像。不幸的是,gnuplot 总是把底线画成白色。以下是应生成全黑 3x3 像素图像的示例:

set term png size 3,3
set out 'test.png'


set xrange [0:2]
set yrange [0:2]
unset xlabel
unset ylabel
set lmargin 0
set rmargin 0
set tmargin 0
set bmargin 0
set size ratio -1
unset xtics
unset ytics
set border 0
unset key

p '-' w rgbimage
0 0 0 0 0
1 0 0 0 0
2 0 0 0 0
0 1 0 0 0
1 1 0 0 0
2 1 0 0 0
0 2 0 0 0
1 2 0 0 0
2 2 0 0 0
e

结果是一张有1条白线和2条黑色像素线的图片:

这是图像查看器的放大屏幕截图,带有灰色框:

有什么办法解决这个问题吗?

我正在使用 gnuplot 5.0

感谢您的帮助。

【问题讨论】:

  • 我知道这对你没有多大帮助,但鉴于 gnuplot 是为绘制图表而设计的,我认为尝试绘制 3x3 图像是对软件的滥用,不符合它的意图。
  • 我刚试过这个,尺寸为 7x7 的图像似乎是不会留下残留白线的最小尺寸。考虑增加图片尺寸。
  • 3x3 图像是演示效果的示例,以使其尽可能简单。图像本身显示科学数据,通常为 400x80 像素大小的矢量场。我喜欢 gnuplot,因为我还可以添加箭头并将其保存为矢量图形,例如 pdf。如果您知道任何其他可以完成这项工作的软件,请告诉我。
  • 在这里你可以找到我想要绘制的数据:filedropper.com/testdata 它是 400x80 像素,并且 gnuplot 在底部绘制了一条白色像素线。最重要的是,这条线失去了顶部像素线。
  • 我建议在Gnuplot info mailinglist 上问这个问题。

标签: gnuplot


【解决方案1】:

我认为拥有 3px 乘以 3px 的图像不是一个合适的用例。当然,表示 3x3 数据矩阵是完全有效的!

似乎在使用某些终端绘制基于像素的数据时存在一些问题。既然你说,最后你想要一个矢量图像(在任何情况下它只会影响你在像素数据上绘制的一些箭头),我只看了一些矢量格式,使用你的例子@ 987654321@和脚本testdata.gp

set autoscale xfix
set autoscale yfix
set margins 0,0,0,0
unset xtics
unset ytics
unset border
unset key

p 'testdata.dat' w rgbimage
  • pdfcairo 不起作用,有一些边界伪影。
  • postscript 工作正常,我用过

    set terminal postscript eps level3 size 8cm,1.6cm
    set output 'testdata.eps'
    load 'testdata.gp'
    set output
    system('epstopdf testdata.eps')
    
  • tikz 也可以正常工作:

    set terminal tikz standalone externalimages size 8cm,1.6cm
    set output 'testdata.tex'
    load 'testdata.gp'
    set output
    system('pdflatex testdata.tex')
    
  • svg 工作正常:

    set terminal svg standalone size 800,160
    set output 'testdata.svg'
    load 'testdata.gp'
    

我还不知道开罗航站楼的实际问题是什么。

【讨论】:

  • 感谢您提供这些解决方法。使用svg,图像的像素结构丢失,这对我的数据来说是有问题的。但是,eps 效果很好。
  • 对于 SVG,像素结构不应该丢失,这可能是您的查看器的人工制品。对于 svg,会生成一个与 (name gp_image...png) 相关联的 PNG
  • 好吧,你是对的。当我将分辨率设置为高于图像中数据点的数量时,它的行为与 png 终端不同。我在每个维度上使用了 4 倍以上的像素来获得尖锐的箭头,并且 svg 终端进行了插值以确定附加像素的值。如果您知道如何使用它,这实际上是一个非常好的功能。
猜你喜欢
  • 2012-04-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-03
  • 2015-07-24
  • 2016-08-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多