matplotlibでhttps://momonoki2017.blogspot.com/2017/12/matplotlib.htmlを参考に図を縦に2つ並べようとしたところ、図が一つしか表示されず、図の中にあるべきプロットが表示されません。
コードは次の通りです。 「#新しく追加」とあるのが、以前のコードに付け足した部分です。
import sys import h5py import numpy as np import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import matplotlib.animation as animation from PIL import Image import moviepy.editor as edit from mpl_toolkits.axes_grid1 import make_axes_locatable def update(k): global vmax global vmin global levels_ plt.cla() # clear axis for i in range(0, 142): for j in range(0, 142): U[i][j] = Ax[j][i][k] #Axは別の場所で代入済み plt.subplot(1, 2, 1) # 新しく追加 plt.contourf(X_vec, Y_vec, U, cmap = "bwr",levels=levels_)# 新しく追加 plt.axes().set_aspect("equal")# 新しく追加 plt.gca().set_ylim([-50, 50])# 新しく追加 plt.gca().set_xlim([-int(argvs[1])*50,int(argvs[1])*50])# 新しく追加 plt.subplot(1, 2, 2) #新しく追加 plt.contourf(X_vec, Y_vec, U, cmap = "bwr",levels=levels_) plt.axes().set_aspect("equal") plt.gca().set_ylim([-50, 50]) plt.gca().set_xlim([-int(argvs[1])*50,int(argvs[1])*50]) ticks_=np.array([-1.5, -1, -0.5, 0, 0.5, 1, 1.5],float) fig=plt.figure() # アニメーション作成 # interval [ms]毎に画像が切り替わる。 # framse回、画像を更新する。updateの第一引数は0,1,2,...,frames-1を動く。 ani = animation.FuncAnimation(fig, update, interval=50 ,frames=400) ani.save("hogehoge.gif", writer='imagemagick')
変更後のgifのスナップショットがこちらです。画像は動画として変化せず、ずっとこのままです。
環境は次の通りです。
$ 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'

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/10/13 12:23
2018/10/13 12:34 編集
2018/10/14 09:36