読者です 読者をやめる 読者になる 読者になる

gnuplot on Homebrew

macOS

gnuplotでグラフ画像を量産したい. というわけで,Homebrewで環境をつくる.

参考は,gnuplotをHomebrewからインストールするときの手順 - QiitaOctaveをMacにインストールする [X11 or AquaTerm] - フェムトセカンド (@melonsode blog) です.

aquaterm にするか X11 にするかだけど,あまりアプリは入れないひとなのでXcodeとかのためすでに入れてる X11 を使う方針でいきます.

gnuplot: stable 5.0.1 (bottled), HEAD
Command-driven, interactive function plotting
http://www.gnuplot.info
Not installed
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/gnuplot.rb
==> Dependencies
Build: pkg-config ✔
Required: fontconfig ✔, jpeg ✔, libpng ✔, libtiff ✔, readline ✔
Recommended: gd ✘, lua ✘
Optional: pdflib-lite ✘, qt ✘, wxmac ✘
==> Options
--with-aquaterm
    Build with AquaTerm support
--with-cairo
    Build the Cairo based terminals
--with-latex
    Build with LaTeX support
--with-pdflib-lite
    Build with pdflib-lite support
--with-qt
    Build with qt support
--with-tests
    Verify the build with make check
--with-wxmac
    Build wxmac support. Need with-cairo to build wxt terminal
--with-x11
    Build with x11 support
--without-emacs
    Do not build Emacs lisp files
--without-gd
    Build without gd support
--without-lua
    Build without the lua/TikZ terminal
--HEAD
    Install HEAD version

X11を使用し,emacsは使わないのでそれを指定. gdとluaも入っちゃうけど,まぁいいか.

user@MacBookPro % brew install gnuplot --with-x11 --without-emacs                                   [~]
==> Installing dependencies for gnuplot: gd, lua
==> Installing gnuplot dependency: gd
==> Downloading https://homebrew.bintray.com/bottles/gd-2.1.1.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring gd-2.1.1.yosemite.bottle.tar.gz
🍺  /usr/local/Cellar/gd/2.1.1: 34 files, 1.2M
==> Installing gnuplot dependency: lua
==> Downloading https://homebrew.bintray.com/bottles/lua-5.2.4_1.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring lua-5.2.4_1.yosemite.bottle.tar.gz
==> Caveats
Please be aware due to the way Luarocks is designed any binaries installed
via Luarocks-5.2 AND 5.1 will overwrite each other in /usr/local/bin.

This is, for now, unavoidable. If this is troublesome for you, you can build
rocks with the `--tree=` command to a special, non-conflicting location and
then add that to your `$PATH`.
==> Summary
🍺  /usr/local/Cellar/lua/5.2.4_1: 81 files, 1.1M
==> Installing gnuplot
==> Downloading https://downloads.sourceforge.net/project/gnuplot/gnuplot/5.0.1/gnuplot-5.0.1.tar.gz
==> Downloading from http://jaist.dl.sourceforge.net/project/gnuplot/gnuplot/5.0.1/gnuplot-5.0.1.tar.gz
######################################################################## 100.0%
==> ./configure --disable-silent-rules --prefix=/usr/local/Cellar/gnuplot/5.0.1 --with-readline=/usr/local/
==> make
==> make install
🍺  /usr/local/Cellar/gnuplot/5.0.1: 46 files, 2.5M, built in 54 seconds

たくさんのCSVからグラフ画像を書き出したいので,ShellScriptからgnuplotを動かします. というわけで,設定を追加.

export GNUTERM=x11

あとは,シェルスクリプトによるデータ処理 をみてかきました. いまは,jpeg出力にも対応してるので,たくさんつくって一気に確認ができて楽ですね.