LoginSignup
148
124

More than 5 years have passed since last update.

gnuplotをHomebrewからインストールするときの手順

Last updated at Posted at 2014-06-25

Macにgnuplotをインストールしようとして、意外とハマったのでその時のメモ。

(2014.12.24 最新の情報にアップデートしました)

(実行環境)

  • OS X 10.10.1 Yosemite
  • Homebrew 0.9.5
  • gnuplot 4.6.6

0. 状況

$ brew install gnuplot だけでもインストールはされる。

しかし、$ gnuplotで起動しても、
Terminal type set to 'unknown' となって、
gnuplot> plot sin(x) とかしても表示ウィンドウが出ない。

出力(表示)先(Terminal type)が指定されていないのがいけないらしい。

1. インストールのオプションを確認

$ brew info gnuplot

==> Options
--cairo
Build the Cairo based terminals
--latex
Build with LaTeX support
--nogd
Build without gd support
--nolua
Build without the lua/TikZ terminal
--pdf
Build the PDF terminal using pdflib-lite
--qt
Build the Qt4 terminal
--tests
Verify the build with make check (1 min)
--with-aquaterm
Build with AquaTerm support
--with-x11
Build with x11 support
--without-emacs
Do not build Emacs lisp files
--wx
Build the wxWidgets terminal using pango
--HEAD
Install HEAD version

インストール時にオプションで出力(表示)先を指定しなくてはいけない様子。

gnuplotでよく使われる出力先としては、AquaTerm(従来はデフォルト)やX11ウィンドウがあるが、Homebrewでは自動でAquaTermやX11は入れてくれない。そこで、自分でインストールする必要がある。

ちなみに、AquaTermは表示がきれい、X11はウィンドウをマウスでドラッグしてグラフの表示を変えられる、という違いがある。

2. AquaTerm、X11のインストール

  • AquaTermのインストール

AquaTermダウンロードページより、ダウンロードしてインストール。(AquaTerm-1.1.1.dmg)
Macintosh HD>アプリケーション フォルダに AquaTerm.appが出来ていればOK。

  • X11のインストール

Mac用の X11ライブラリ XQuartzダウンロードページより、ダウンロードしてインストール。(XQuartz-2.7.7.dmg)
Macintosh HD>アプリケーション>ユーティリティ フォルダに X11.appが出来ていればOK。

3. gnuplotのインストール

$ brew uninstall gnuplot  #一旦 gnuplotをアンインストールする
$ brew install gnuplot --with-aquaterm --with-x11

ここでは、AquaTermとX11の両方を指定してみた。

4. gnuplotを起動して確認

$ gnuplotで起動。
Terminal type set to 'aqua' とメッセージが表示されれば、AquaTermが出力先に設定されている。

gnuplot> plot sin(x) でAquaTermのウィンドウが開いて、サインカーブのグラフが表示されればOK。

5. 出力先の設定

  • 指定可能な出力先のリストを表示させる
gnuplot> set terminal  #指定可能な出力先のリストを表示

Available terminal types:
             aqua  Interface to graphics terminal server for Mac OS X
           canvas  HTML Canvas object

            ###(中略)###

              x11  X11 Window System
             xlib  X11 Window System (gnulib_x11 dump)
            xterm  Xterm Tektronix 4014 Mode

 

  • AquaTermからX11に切り替えてみる
gnuplot> set terminal x11
Terminal type set to 'x11'
Options are ' nopersist'
gnuplot> plot sin(x)
#X11ウィンドウが開いて、サインカーブのグラフが表示されればOK

 
 ちなみに;

Options are 'nopersist' はgnuplotを終了またはresetした後は描画も消してしまうオプション。これがデフォルト。persistにすれば終了またはリセット後も描画は表示され続ける。
(→・windows8上の仮想環境でubuntu13.10を使っているのですが、gnuplotを使... - Yahoo!知恵袋

 

  • X11からAquaTermに切り替えてみる
gnuplot> set terminal aqua
Terminal type set to 'aqua'
Options are '0 title "Figure 0" size 846,594 font "Times-Roman,14" noenhanced solid'
gnuplot> plot sin(x)
#AquaTermウィンドウが開いて、サインカーブのグラフが表示されればOK

 

参考)

→・Homebrewでgnuplotを入れる -xeno1991 -Qiita
 

148
124
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
148
124