【发布时间】:2015-11-17 09:43:14
【问题描述】:
我按顺序使用imsave() 制作了许多PNG,我将它们组合成一个AVI,我想添加移动文本注释。我使用ImageJ 制作 AVI 或 GIF。
我不想要坐标轴、数字、边框或任何东西,只想要带有文本(可能还有箭头)的彩色图像(例如imsave() 提供的)。这些将逐帧更改。请原谅使用喷气机。
我可以使用 savefig() 并关闭标记,然后进行裁剪作为后期处理,但是有没有更方便、直接或“matplotlibithic”的方式来做到这一点,这对我的硬盘来说不会那么难? (最后的事情会非常大)。
一个代码sn-p,由请求添加:
import numpy as np
import matplotlib.pyplot as plt
nx, ny = 101, 101
phi = np.zeros((ny, nx), dtype = 'float')
do_me = np.ones_like(phi, dtype='bool')
x0, y0, r0 = 40, 65, 12
x = np.arange(nx, dtype = 'float')[None,:]
y = np.arange(ny, dtype = 'float')[:,None]
rsq = (x-x0)**2 + (y-y0)**2
circle = rsq <= r0**2
phi[circle] = 1.0
do_me[circle] = False
do_me[0,:], do_me[-1,:], do_me[:,0], do_me[:,-1] = False, False, False, False
n, nper = 100, 100
phi_hold = np.zeros((n+1, ny, nx))
phi_hold[0] = phi
for i in range(n):
for j in range(nper):
phi2 = 0.25*(np.roll(phi, 1, axis=0) +
np.roll(phi, -1, axis=0) +
np.roll(phi, 1, axis=1) +
np.roll(phi, -1, axis=1) )
phi[do_me] = phi2[do_me]
phi_hold[i+1] = phi
change = phi_hold[1:] - phi_hold[:-1]
places = [(32, 20), (54,25), (11,32), (3, 12)]
plt.figure()
plt.imshow(change[50])
for (x, y) in places:
plt.text(x, y, "WOW", fontsize=16)
plt.text(5, 95, "Don't use Jet!", color="white", fontsize=20)
plt.show()
【问题讨论】:
标签: animation numpy video matplotlib png