GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 16.04 LTS desktop amd64
TensorFlow v1.1.0
cuDNN v5.1 for Linux
CUDA v8.0
Python 3.5.2
IPython 6.0.0 -- An enhanced Interactive Python.
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
現在読んでいるPython/Numpy/Scipy/Pandas/Matplotlib/Numba/Numexpr/...に関する本の中で、以下のような記述がある。
...
plt.figure(略)
plt.clf()
plt.axes(略)
...
plt.clf()といのはClear the current figure.という意味のようだ。
https://matplotlib.org/devdocs/api/_as_gen/matplotlib.pyplot.clf.html
Matplotlibでセル単位で描画コードを走らす場合、「前の図」というのが残っているわけではないように思う。
そのため、plt.clf()は不要なのではないかと思っている。
あるいは、plt.figure(略)の描画が残すものをクリアするという意味なのかもしれない。
実際の動きについては未確認。
コード例
Fancybox Demo
においては以下のようにtest_all()の最初でplt.clf()を行っている。
def test_all():
plt.clf()
link
When to use cla(), clf() or close() for clearing a plot in matplotlib?
Whereas this one will produce a list with five figures on it.
for i in range(5):
fig = plot_figure()
fig.clf()
# This returns a list with all figure numbers available
print(plt.get_fignums())
先に5つのfigureを作り、(それをクリアしてから)後で再利用する、という意味なのかもしれない。