XubuntuにデフォルトインストールされているPython3にて、matplotlibでコサイン関数を描くプログラムを書いてみたところ、何やらエラーが出ました。
■cos.py
import numpy as np import matplotlib.pyplot as plt x = np.arange(0, np.pi * 2, 0.1) y = np.cos(x) plt.plot(x, y) plt.show()
■実行
$ python3 cos.py UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
解決策
python3-tkをインストールする。
$ sudo apt install -y python3-tk
もう一度実行。
$ python3 cos.py
よし、成功。