pythonのmatplotlibを利用してグラフを作っています。
以前、動画を二つ並べる方法を教えていただき、
そのコードを改造して、1つだけにしようとしたところで、つまずいています。
改造手出来たコードは下のようになっています。
import numpy as np import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation from PIL import Image def update(time, ax): x = np.empty((100), float) y = np.empty((100), float) for i in range(100): x[i] = 2 * np.pi * i / 100 for i in range(100): y[i] = np.sin(x[i] + time * 0.1) ax.clear() ax.plot(x, y, color='black') fig, [ax] = plt.subplots(1, 1,figsize=(1,1)) anim = FuncAnimation(fig, update, fargs=(ax), interval=100, frames=100) anim.save('fig.gif', writer='imagemagick')
このコードを実行すると次のエラーが出ます。
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime' Traceback (most recent call last): File "test.py", line 17, in <module> fig, [ax] = plt.subplots(1, 1,figsize=(1,1)) TypeError: 'AxesSubplot' object is not iterable
原因・解決方法のわかる方、ご教授ください。
環境は次の通りです。
$ python Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56) [GCC 7.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import matplotlib >>> matplotlib.__version__ '2.2.2'

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/10/15 01:37