macOS Sierra (10.12.3)にOctaveをインストールできなくて困った話の続きです。
さて、octave(とgnuplot)をインストールしたのですが、plot()
ができないことに気が付きました。plot()
すると、以下のようなerrorが出て、グラフが表示されません。
Fontconfig error: line 86: not well-formed (invalid token)
Fontconfig error: Cannot load default config file
warning: could not match any font: *-normal-normal-10
gnuplotは、brew install gnuplot --with-aquaterm
でインストールしてある状態で、.octavercは、以下のようになっています。
graphics_toolkit("gnuplot");
setenv("GNUTERM", "aqua");
octaveとgnuplotのバージョンは、それぞれ次のようになっています。
% octave --version
GNU Octave, version 4.2.1
Copyright (C) 2017 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
Octave was configured for "x86_64-apple-darwin16.4.0".
Additional information about Octave is available at http://www.octave.org.
Please contribute if you find this software useful.
For more information, visit http://www.octave.org/get-involved.html
Read http://www.octave.org/bugs.html to learn how to submit bug reports.
% gnuplot --version
gnuplot 5.0 patchlevel 6
font config fileの問題?
86行目に問題がある(line 86: not well-formed (invalid token)
)とのことなので、fonts.confファイルを探してみます。
~/Library/Fonts/ には、fonst.list、fonts.dir、fonts.scaleのファイルがありますが、fonts.confはありません。
/usr/local/Cellar/fontconfig/2.12.1_2/share/fontconfig/conf.avail 以下には.confファイルが沢山ありますが、これらのうちのどれかに問題があるのか、よく分かりません。
エラーメッセージで検索してみた結果
色々と検索してみたところ、stackoverflowに、答えがありました。
どうやら、環境変数FONTCONFIG_PATH
が設定されていなかったのが問題だったようです。FONTCONFIG_PATH
として/opt/X11/lib/X11/fontconfig
を設定すると、octaveでplot()
した時に、ちゃんとグラフが表示されるようになりました。
bash、zshの場合
.bashrc、.zshrcなどに、以下のように記載します。
export FONTCONFIG_PATH=/opt/X11/lib/X11/fontconfig
csh、tcshの場合
.cshrc、.tcshrcなどに、以下のように記載します。
setenv FONTCONFIG_PATH /opt/X11/lib/X11/fontconfig
fishの場合
.config/fish/config.fishなどに、以下のように記載します。
set -x FONTCONFIG_PATH /opt/X11/lib/X11/fontconfig
今回のサマリ
octave(とgnuplot)で、グラフ等を描画する場合は、環境変数FONTCONFIG_PATHを正しく設定しておく必要があるということが分かりました。