使用Gnuplot时终端“png”丢失

9

我正在使用Xubuntu 13.10,并通过手动编译安装了gnuplot。但是,当我测试“plot”功能时,出现了错误:

$ python PlotSccDistr.py                            

set terminal png size 1000,800
             ^
"scc.example.plt", line 16: unknown or ambiguous terminal type; type just 'set terminal' for a list

如果我想设置终端PNG格式,但在我的列表中找不到"PNG":

$ gnuplot

    G N U P L O T
    Version 4.6 patchlevel 5    last modified February 2014
    Build System: Linux x86_64

    Copyright (C) 1986-1993, 1998, 2004, 2007-2014
    Thomas Williams, Colin Kelley and many others

    gnuplot home:     http://www.gnuplot.info
    faq, bugs, etc:   type "help FAQ"
    immediate help:   type "help"  (plot window: hit 'h')

    Terminal type set to 'x11'

gnuplot> set terminal

       canvas  HTML Canvas object
          cgm  Computer Graphics Metafile
      context  ConTeXt with MetaFun (for PDF documents)
        corel  EPS format for CorelDRAW
         dumb  ascii art for anything that prints text
          dxf  dxf-file for AutoCad (default size 120x80)
        eepic  EEPIC -- extended LaTeX picture environment
          emf  Enhanced Metafile format
        emtex  LaTeX picture environment with emTeX specials
     epslatex  LaTeX picture environment using graphicx package
          fig  FIG graphics language for XFIG graphics editor
         gpic  GPIC -- Produce graphs in groff using the gpic preprocessor
      hp2623A  HP2623A and maybe others
       hp2648  HP2648 and HP2647
         hpgl  HP7475 and relatives [number of pens] [eject]
       imagen  Imagen laser printer
        latex  LaTeX picture environment
           mf  Metafont plotting standard
          mif  Frame maker MIF 3.00 format
           mp  MetaPost plotting standard
         pcl5  HP Designjet 750C, HP Laserjet III/IV, etc. (many options)
   postscript  PostScript graphics, including EPSF embedded files (*.eps)
      pslatex  LaTeX picture environment with PostScript \specials
        pstex  plain TeX with PostScript \specials
     pstricks  LaTeX picture environment with PSTricks macros
          qms  QMS/QUIC Laser printer (also Talaris 1200 and others)
        regis  REGIS graphics language
          svg  W3C Scalable Vector Graphics driver
      tek40xx  Tektronix 4010 and others; most TEK emulators
      tek410x  Tektronix 4106, 4107, 4109 and 420X terminals
      texdraw  LaTeX texdraw environment
         tgif  TGIF X11 [mode] [x,y] [dashed] ["font" [fontsize]]
     tkcanvas  Tk/Tcl canvas widget [perltk] [interactive]
         tpic  TPIC -- LaTeX picture environment with tpic \specials
      unknown  Unknown terminal type - not a plotting device
        vttek  VT-like tek40xx terminal emulator
          x11  X11 Window System
         xlib  X11 Window System (gnulib_x11 dump)
        xterm  Xterm Tektronix 4014 Mode

有人能帮我吗?谢谢!!!

1
由于"png"不在支持的终端类型列表中,因此似乎在编译之前配置了gnuplot生成而未包含PNG支持。如果您希望它存在,您将需要重新配置和重建以包括PNG支持... - twalberg
查看编译时可用的标志,我认为命令是 ./configure --help - andyras
1
你必须安装一堆开发包才能使用*cairo和wxt终端构建gnuplot。在Debian上,需要安装libcairo2-devlibpango1.0-devwx2.8-headers等许多其他包。 - Christoph
就像我说的:你需要更多的软件包,我没有完整的列表,但那只是为了展示其中一些。你应该尝试使用cairo终端进行构建,因为它们可以提供更好的输出效果!安装dev软件包,这是Xubuntu gnuplot软件包所需的,并再次尝试:apt-rdepends --build-depends --follow=DEPENDS gnuplot,参见http://askubuntu.com/questions/21379/how-do-i-find-the-build-dependencies-of-a-package。你可以省略与texlive相关的软件包。 - Christoph
@Christoph 非常感谢!!!不仅感谢您提供的解决方案,还有 apt-rdepends 这个有用的命令!太棒了!! - Destec
显示剩余3条评论
4个回答

7

png终端不可用的原因是它是基于libgd开发的终端,与jpeg和gif一样。对于这些终端,gnuplot需要libgd版本>=2.0。要使其可用,您需要首先安装GD图形库:

$ sudo apt-get install libgd2-dev

然后安装gnuplot并检查是否存在png终端:
gnuplot> set terminal

Available terminal types:
              ...
              gif  GIF images using libgd and TrueType fonts
              ...
             jpeg  JPEG images using libgd and TrueType fonts
              ...
              png  PNG images using libgd and TrueType fonts
              ...

3

我在基于Ubuntu 16.04的Linux Mint上安装了gnuplot5.2.2,并成功地在“set terminal”中设置了“png”。

我安装了这些库。

sudo apt-get install libcairo2-dev libpango1.0-dev libgd-dev

接下来我重新运行了./configure,然后运行make、make check和make install。

在阅读./configure的输出时,似乎cairo确实是必要的,正如问题的评论中https://stackoverflow.com/users/2604213/christoph所提到的。

这是在运行./configure之后的配置摘要:

** Configuration summary for gnuplot 5.2.2:

gnuplot will be compiled with the following terminals:

  Standalone terminals: yes (always builtin)
    canvas, cgm, context, dumb, dxf, eepic, emf, emtex,
    epslatex, fig, hpgl, latex, metafont, metapost, mif, pcl5,
    postscript, pslatex, pstex, pstricks, qms, svg,
    tek40xx, tek410x, texdraw, tgif, tkcanvas, tpic, vttek

  dot-matrix terminals: no (use --with-bitmap-terminals to enable)
    epson, nec, okidata, tandy, and seiko dp414 printers
    hp500c, hpdj, hpljii, hppj, pbm, sixel, starc

  X Window System terminal: yes
    (with multi-byte fonts)
    (enable plotting to windows opened by external apps) 
    (with application defaults, in /etc/X11/app-defaults/)
  linux terminal (vga console): no (use --with-linux-vga to enable)
  vgagl terminal ((s)vga console): no (use --with-linux-vga to enable)
  ggi terminal: no (use --with-ggi to enable, requires libggi)
  gpic terminal: no   (use --with-gpic to enable)
  mif terminal: no   (use --with-mif to enable)
  caca terminal: no (use --with-caca to enable)
  aqua terminal (OSX): no
  libgd-based png, jpeg, and gif terminals: yes (with animated gif)
  cairo-based pdf and png terminals: yes 
  lua/TikZ terminal: no 
  wxt terminal: yes 
  Qt terminal: no (use --with-qt or --with-qt=qt4 to enable

1
我得到PNG终端的方法是输入 sudo apt-get install libgd2-noxpm-dev 然后重新编译和安装gnuplot。

0
在 Fedora 27 中,您可以通过安装 gnuplot-wx.x86_64 来解决问题:gnuplot 的 Qt 接口。
sudo dnf install gnuplot-wx

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接