LoginSignup
29
21

More than 5 years have passed since last update.

[短文メモ]matplotlibで、showしても何も表示されない→backend設定を確認

Posted at

backendがGUIのものになっていない可能性がある。

import matplotlib as mpl
mpl.use('tkagg')

を、import matplotlib.pyplot`よりも先に評価する(上の行に書く)。

ImportError: No module named backend_tkagg.pyと表示される場合:
バックエンドがインストールされていないっぽい。apt-getなりyumなりでインストールが必要。
SUSEの場合は、
sudo zypper in python-matplotlib-tk (Python3の場合は python3-matplotlib-tk)

できるようになったけど毎回これやるの面倒
matplotlibrcファイルに記述する。

~/.config/matplotlib/matplotlibrc
backend : tkagg

Linuxの場合は、.config/matplotlib/matplotlibrc
その他のプラットホームでは、.matplotlib/matplotlibrc
分からなければ

import matplotlib as mpl
print(mpl.get_configdir() + '/matplotlibrc')

参考

http://python.dogrow.net/?p=186
http://matplotlib.org/users/customizing.html

29
21
0

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
29
21