Gnuplot:安装与使用备忘

异常信息

问题起源于 signalp-4.1 调用 gnuplot 进行画图,在画图的时候提示不支持 png 格式结果:

$ gnuplot

        G N U P L O T
        Version 5.0 patchlevel 0    last modified 2015-01-01

        Copyright (C) 1986-1993, 1998, 2004, 2007-2015
        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 term png font "Helvetica,12"  # 您必须在绘图前设置终端和输出文件名
Terminal type set to 'unknown'
                  ^
         unknown or ambiguous terminal type; type just 'set terminal' for a list

gnuplot> set term png font "Helvetica,12";
Terminal type set to 'unknown'
                  ^
         unknown or ambiguous terminal type; type just 'set terminal' for a list

gnuplot> set terminal # 查看 gnuplot 支持的设置格式

Available terminal types:
           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
             hpgl  HP7475 and relatives [number of pens] [eject]
            latex  LaTeX picture environment
               mf  Metafont plotting standard
               mp  MetaPost plotting standard
             pcl5  HP Designjet 750C, HP Laserjet III/IV, etc. (many options)
             ......

因此考虑重装 gnuplot,以支持 png, jpeg, and gif terminals,具体步骤如下。

安装 GD library 库

GD (https://github.com/libgd/libgd)是一个用于程序员动态创建和处理图像的开源库。手动安装步骤如下。

$ curl -LjO https://github.com/libgd/libgd/releases/download/gd-2.2.5/libgd-2.2.5.tar.gz
$ tar zvxf libgd-2.2.5.tar.gz
$ cd libgd-2.2.5
$ ./configure --prefix=/Bioinfo/SoftWare/libgd-2.2.5
$ make 
$ make install

安装 Gnuplot
官网:http://www.gnuplot.info/
注意:
1
configure 时需要把前一步安装好的 libgd 加进去;
2
make install 如遇一下类似 Permission denied, 可忽略,不影响使用。

$ wget http://ftp.cstug.cz/pub/CTAN/graphics/gnuplot/5.2.6/gnuplot-5.2.6.tar.gz
$ tar zvxf gnuplot-5.2.6.tar.gz
$ cd gnuplot-5.2.6
$ ./configure --prefix=/Bioinfo/SoftWare/gnuplot-5.2.6 --with-gd=/Bioinfo/SoftWare/libgd-2.2.5 LDFLAGS="-L/Bioinfo//SoftWare/libgd-2.2.5/lib" CPPFLAGS="-I/Bioinfo/SoftWare/libgd-2.2.5/include" 
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
......
** Configuration summary for gnuplot 5.2.6:

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 terminals: no (requires cairo>=1.2, pango>=1.22, glib>=2.28)
  lua/TikZ terminal: no
  wxt terminal: no (requires C++, wxWidgets>2.6, cairo>0.9, pango>1.22)
  Qt terminal: yes (qt4)

  Additional platform-specific or older terminals omitted by default:
   gpic, mif (FrameMaker 3), hp2623a, hp2648, imagen, kyocera
   pm (makefile.os2), be (BeOS), svga (MSDOS/djgpp)
   windows (several options)

gnuplot will be compiled with the following configurable features:

  Mouse support in interactive terminals: yes
  Typing  in plot window raises console
  Placement of rectangles and other objects: yes
  Readline library: GNU readline library with  -lncurses
  Command-line history file: yes
  Check current directory for .gnuplot file: no (use --with-cwdrc to enable)
  Sort help/subtopic tables by column: no (use --without-row-help to enable)
  cerf() and other special functions: no (libcerf not found)
  plugin support for loading external functions: yes
  Use TeX kpsexpand to search for fonts: no (use --with-kpsexpand to enable)
  Hidden3d optimization (gridbox/quadtree/none): quadtree
  Allow deprecated syntax: no (use --enable-backwards-compatibility)
  Statistical summary of data ("stats" command): yes
......
$ make
$ make install 
# 如遇一下 Permission denied, 可忽略,不影响使用
......
make[3]: Nothing to be done for `install-exec-am'.
 /bin/mkdir -p '/Bioinfo/APPS/texlive/texmf-local/tex/latex/gnuplot'
/bin/mkdir: cannot create directory `/Bioinfo/APPS/texlive/texmf-local/tex/latex/gnuplot': Permission denied
make[3]: *** [install-texDATA] Error 1
make[3]: Leaving directory `/Bioinfo/Pipeline/src/pkgs/gnuplot-5.2.6/share/LaTeX'
make[2]: *** [install-am] Error 2
make[2]: Leaving directory `/Bioinfo/Pipeline/src/pkgs/gnuplot-5.2.6/share/LaTeX'
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory `/Bioinfo/Pipeline/src/pkgs/gnuplot-5.2.6/share'
make: *** [install-recursive] Error 1

Gnuplot:安装与使用备忘_第1张图片
注意:configure 的提示(libgd-based png, jpeg, and gif terminals: yes)

  1. 集群运行时,如遇上以下报错,执行一下ldd /Bioinfo/SoftWare/gnuplot-5.2.6/bin/gnuplot,把缺失的对应指向的 libQt*.so 拷贝到一个指定目录,然后增加一个export LD_LIBRARY_PATH=/Bioinfo/SoftWare/gnuplot-5.2.6/customlib:$LD_LIBRARY_PATH即可。
gnuplot: error while loading shared libraries: libQtNetwork.so.4: cannot open shared object file: No such file or directory

Gnuplot:安装与使用备忘_第2张图片

简单绘图

安装完成后,进入 gnuplot 简单画图并保存为 plot.png。

gnuplot> set term png font "Helvetica,12"

Terminal type is now 'png'
Options are 'nocrop enhanced size 640,480 font "Helvetica,12.0" '
gnuplot> set output "plot.png"
gnuplot> plot sin(x)
gnuplot> exit

Gnuplot:安装与使用备忘_第3张图片

你可能感兴趣的:(linux)