def plot_summed_patterns_one_point(row,col):
# sum the diffrtaction patterns in one point
summed_point = 0
for j in range(0,nbr_rotations):
summed_point = summed_point + list_Merlin[j][row][col].toarray()
plt.figure()
plt.imshow(np.log10(summed_point), cmap = 'hot', interpolation = 'none')
plt.axis('off')
plt.colorbar()
plt.title('masked diffraction patterns sum of one position in %d scans'%nbr_rotations)
#plot_summed_patterns_one_point(8,49) #inser col and row you want to plot
# # anim TABORT
# im = plt.imshow(abs(objectFunc), animated=True, interpolation='none', extent=[0,6.837770297837617,0,6.825238081022181])
#
# ims.append([im])
# ani = animation.ArtistAnimation(fig, ims, interval=1500, blit=True,repeat_delay=2000)
# plt.show()
# plot diffraction patterns merlin + pilK100
python类ArtistAnimation()的实例源码
load_data_plot3Dpeak.py 文件源码
项目:CoherentXrayImaging
作者: susannahammarberg
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
def draw_MRI(image_3d_gray, interval = 50, repeat_delay=500):
"""
draws a 3d image in time laps
image_3d_gray : 3d numpy array of gray scale
"""
fig = plt.figure()
ims = []
for i in range(image_3d_gray.shape[0]):
im = plt.imshow(image_3d_gray[i], cmap = "Greys_r")
ims.append([im])
ani = animation.ArtistAnimation(fig, ims, interval=interval, blit=False, repeat_delay=repeat_delay)
plt.show()
def animate(self):
"""animate function for actually generating figure from Animation instance.
"""
ani = animation.ArtistAnimation(self.fig, self.frames, interval=self.interval, blit=self.blit, repeat_delay=self.repeat_delay)
plt.axis('off')
plt.show()
def build_gif(imgs, interval=0.1, dpi=72,
save_gif=True, saveto='animation.gif',
show_gif=False, cmap=None):
"""Take an array or list of images and create a GIF.
Parameters
----------
imgs : np.ndarray or list
List of images to create a GIF of
interval : float, optional
Spacing in seconds between successive images.
dpi : int, optional
Dots per inch.
save_gif : bool, optional
Whether or not to save the GIF.
saveto : str, optional
Filename of GIF to save.
show_gif : bool, optional
Whether or not to render the GIF using plt.
cmap : None, optional
Optional colormap to apply to the images.
Returns
-------
ani : matplotlib.animation.ArtistAnimation
The artist animation from matplotlib. Likely not useful.
"""
imgs = np.asarray(imgs)
h, w, *c = imgs[0].shape
fig, ax = plt.subplots(figsize=(np.round(w / dpi), np.round(h / dpi)))
fig.subplots_adjust(bottom=0)
fig.subplots_adjust(top=1)
fig.subplots_adjust(right=1)
fig.subplots_adjust(left=0)
ax.set_axis_off()
if cmap is not None:
axs = list(map(lambda x: [
ax.imshow(x, cmap=cmap)], imgs))
else:
axs = list(map(lambda x: [
ax.imshow(x)], imgs))
ani = animation.ArtistAnimation(
fig, axs, interval=interval, repeat_delay=0, blit=False)
if save_gif:
ani.save(saveto, writer='imagemagick', dpi=dpi)
if show_gif:
plt.show()
return ani