当前位置: 首页>>代码示例>>Python>>正文


Python axes_grid1.ImageGrid方法代码示例

本文整理汇总了Python中mpl_toolkits.axes_grid1.ImageGrid方法的典型用法代码示例。如果您正苦于以下问题:Python axes_grid1.ImageGrid方法的具体用法?Python axes_grid1.ImageGrid怎么用?Python axes_grid1.ImageGrid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mpl_toolkits.axes_grid1的用法示例。


在下文中一共展示了axes_grid1.ImageGrid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: demo_simple_grid

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import ImageGrid [as 别名]
def demo_simple_grid(fig):
    """
    A grid of 2x2 images with 0.05 inch pad between images and only
    the lower-left axes is labeled.
    """
    grid = ImageGrid(fig, 141,  # similar to subplot(141)
                     nrows_ncols=(2, 2),
                     axes_pad=0.05,
                     label_mode="1",
                     )

    Z, extent = get_demo_image()
    for i in range(4):
        im = grid[i].imshow(Z, extent=extent, interpolation="nearest")

    # This only affects axes in first column and second row as share_all =
    # False.
    grid.axes_llc.set_xticks([-2, 0, 2])
    grid.axes_llc.set_yticks([-2, 0, 2]) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:21,代码来源:demo_axes_grid.py

示例2: demo_grid_with_single_cbar

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import ImageGrid [as 别名]
def demo_grid_with_single_cbar(fig):
    """
    A grid of 2x2 images with a single colorbar
    """
    grid = ImageGrid(fig, 142,  # similar to subplot(142)
                     nrows_ncols=(2, 2),
                     axes_pad=0.0,
                     share_all=True,
                     label_mode="L",
                     cbar_location="top",
                     cbar_mode="single",
                     )

    Z, extent = get_demo_image()
    for i in range(4):
        im = grid[i].imshow(Z, extent=extent, interpolation="nearest")
    grid.cbar_axes[0].colorbar(im)

    for cax in grid.cbar_axes:
        cax.toggle_label(False)

    # This affects all axes as share_all = True.
    grid.axes_llc.set_xticks([-2, 0, 2])
    grid.axes_llc.set_yticks([-2, 0, 2]) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:26,代码来源:demo_axes_grid.py

示例3: imshow_grid

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import ImageGrid [as 别名]
def imshow_grid(images, shape=[2, 8], name='default', save=False):
    """
    Plot images in a grid of a given shape.
    Initial code from: https://github.com/pumpikano/tf-dann/blob/master/utils.py
    """
    fig = plt.figure(1)
    grid = ImageGrid(fig, 111, nrows_ncols=shape, axes_pad=0.05)

    size = shape[0] * shape[1]
    for i in range(size):
        grid[i].axis('off')
        grid[i].imshow(images[i])  # The AxesGrid object work as a list of axes.

    if save:
        plt.savefig('reconstructed_images/' + str(name) + '.png')
        plt.clf()
    else:
        plt.show() 
开发者ID:ananyahjha93,项目名称:cycle-consistent-vae,代码行数:20,代码来源:utils.py

示例4: show_samples

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import ImageGrid [as 别名]
def show_samples(images, row, col, image_shape, name="Unknown", save=True, shift=False):
    num_images = row*col
    if shift:
        images = (images+1.)/2.
    fig = plt.figure(figsize=(col, row))
    grid = ImageGrid(fig, 111,
                     nrows_ncols=(row, col),
                     axes_pad=0.)
    for i in xrange(num_images):
        im = images[i].reshape(image_shape)
        axis = grid[i]
        axis.axis('off')
        axis.imshow(im)
    plt.axis('off')
    plt.tight_layout()
    if save:
        fig.savefig('figs/train/grid/'+name+'.png', bbox_inches="tight", pad_inches=0, format='png')
    else:
        plt.show()


#From some github code 
开发者ID:wuga214,项目名称:IMPLEMENTATION_Variational-Auto-Encoder,代码行数:24,代码来源:grid_plots.py

示例5: plot_matrix

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import ImageGrid [as 别名]
def plot_matrix(A,cbar_location='right',figsize=(18,18),cmap='coolwarm',fname=None):
    fig = plt.figure(figsize=figsize)
    axes = ImageGrid(fig, 111,  # similar to subplot(111)
                 nrows_ncols=(1,1),
                 axes_pad=2.0,
                 add_all=True,
                 label_mode="L",
                 cbar_mode = 'each',
                 cbar_location = cbar_location,
                 cbar_pad='2%'
                 )
    im = axes[0].imshow(A,cmap=cmap,interpolation='none')
    axes.cbar_axes[0].colorbar(im)
    if fname is None:
        plt.show()
    else:
        plt.savefig(fname)
    return fig,axes 
开发者ID:igp-gravity,项目名称:geoist,代码行数:20,代码来源:utils.py

示例6: plotFields

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import ImageGrid [as 别名]
def plotFields(layer,fieldShape=None,channel=None,figOffset=1,cmap=None,padding=0.01):
	# Receptive Fields Summary
	try:
		W = layer.W
	except:
		W = layer
	wp = W.eval().transpose();
	if len(np.shape(wp)) < 4:		# Fully connected layer, has no shape
		fields = np.reshape(wp,list(wp.shape[0:-1])+fieldShape)	
	else:			# Convolutional layer already has shape
		features, channels, iy, ix = np.shape(wp)
		if channel is not None:
			fields = wp[:,channel,:,:]
		else:
			fields = np.reshape(wp,[features*channels,iy,ix])

	perRow = int(math.floor(math.sqrt(fields.shape[0])))
	perColumn = int(math.ceil(fields.shape[0]/float(perRow)))

	fig = mpl.figure(figOffset); mpl.clf()
	
	# Using image grid
	from mpl_toolkits.axes_grid1 import ImageGrid
	grid = ImageGrid(fig,111,nrows_ncols=(perRow,perColumn),axes_pad=padding,cbar_mode='single')
	for i in range(0,np.shape(fields)[0]):
		im = grid[i].imshow(fields[i],cmap=cmap); 

	grid.cbar_axes[0].colorbar(im)
	mpl.title('%s Receptive Fields' % layer.name)
	
	# old way
	# fields2 = np.vstack([fields,np.zeros([perRow*perColumn-fields.shape[0]] + list(fields.shape[1:]))])
	# tiled = []
	# for i in range(0,perColumn*perRow,perColumn):
	# 	tiled.append(np.hstack(fields2[i:i+perColumn]))
	# 
	# tiled = np.vstack(tiled)
	# mpl.figure(figOffset); mpl.clf(); mpl.imshow(tiled,cmap=cmap); mpl.title('%s Receptive Fields' % layer.name); mpl.colorbar();
	mpl.figure(figOffset+1); mpl.clf(); mpl.imshow(np.sum(np.abs(fields),0),cmap=cmap); mpl.title('%s Total Absolute Input Dependency' % layer.name); mpl.colorbar() 
开发者ID:robb-brown,项目名称:IntroToDeepLearning,代码行数:41,代码来源:TensorFlowInterface.py

示例7: plotFields

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import ImageGrid [as 别名]
def plotFields(layer,fieldShape=None,channel=None,maxFields=25,figName='ReceptiveFields',cmap=None,padding=0.01):
	# Receptive Fields Summary
	W = layer.W
	wp = W.eval().transpose();
	if len(np.shape(wp)) < 4:		# Fully connected layer, has no shape
		fields = np.reshape(wp,list(wp.shape[0:-1])+fieldShape)
	else:			# Convolutional layer already has shape
		features, channels, iy, ix = np.shape(wp)
		if channel is not None:
			fields = wp[:,channel,:,:]
		else:
			fields = np.reshape(wp,[features*channels,iy,ix])

	fieldsN = min(fields.shape[0],maxFields)
	perRow = int(math.floor(math.sqrt(fieldsN)))
	perColumn = int(math.ceil(fieldsN/float(perRow)))

	fig = mpl.figure(figName); mpl.clf()

	# Using image grid
	from mpl_toolkits.axes_grid1 import ImageGrid
	grid = ImageGrid(fig,111,nrows_ncols=(perRow,perColumn),axes_pad=padding,cbar_mode='single')
	for i in range(0,fieldsN):
		im = grid[i].imshow(fields[i],cmap=cmap);

	grid.cbar_axes[0].colorbar(im)
	mpl.title('%s Receptive Fields' % layer.name)

	# old way
	# fields2 = np.vstack([fields,np.zeros([perRow*perColumn-fields.shape[0]] + list(fields.shape[1:]))])
	# tiled = []
	# for i in range(0,perColumn*perRow,perColumn):
	# 	tiled.append(np.hstack(fields2[i:i+perColumn]))
	#
	# tiled = np.vstack(tiled)
	# mpl.figure(figOffset); mpl.clf(); mpl.imshow(tiled,cmap=cmap); mpl.title('%s Receptive Fields' % layer.name); mpl.colorbar();
	mpl.figure(figName+' Total'); mpl.clf(); mpl.imshow(np.sum(np.abs(fields),0),cmap=cmap); mpl.title('%s Total Absolute Input Dependency' % layer.name); mpl.colorbar() 
开发者ID:robb-brown,项目名称:IntroToDeepLearning,代码行数:39,代码来源:TensorFlowInterface.py

示例8: imshow_grid

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import ImageGrid [as 别名]
def imshow_grid(images, shape=[2, 8]):
    """Plot images in a grid of a given shape."""
    fig = plt.figure(1)
    grid = ImageGrid(fig, 111, nrows_ncols=shape, axes_pad=0.05)
    n_dim = np.shape(images)
    size = shape[0] * shape[1]
    for i in range(size):
        grid[i].axis('off')
        if len(n_dim)<=3:
           grid[i].imshow(images[i], cmap=plt.get_cmap('gray'))  # The AxesGrid object work as a list of axes.
        else:
           grid[i].imshow(images[i]) 
        
        
    plt.show() 
开发者ID:bbdamodaran,项目名称:deepJDOT,代码行数:17,代码来源:utlis.py

示例9: demo_grid_with_each_cbar

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import ImageGrid [as 别名]
def demo_grid_with_each_cbar(fig):
    """
    A grid of 2x2 images. Each image has its own colorbar.
    """

    grid = ImageGrid(fig, 143,  # similar to subplot(143)
                     nrows_ncols=(2, 2),
                     axes_pad=0.1,
                     label_mode="1",
                     share_all=True,
                     cbar_location="top",
                     cbar_mode="each",
                     cbar_size="7%",
                     cbar_pad="2%",
                     )
    Z, extent = get_demo_image()
    for i in range(4):
        im = grid[i].imshow(Z, extent=extent, interpolation="nearest")
        grid.cbar_axes[i].colorbar(im)

    for cax in grid.cbar_axes:
        cax.toggle_label(False)

    # This affects all axes because we set share_all = True.
    grid.axes_llc.set_xticks([-2, 0, 2])
    grid.axes_llc.set_yticks([-2, 0, 2]) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:28,代码来源:demo_axes_grid.py

示例10: demo_grid_with_each_cbar_labelled

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import ImageGrid [as 别名]
def demo_grid_with_each_cbar_labelled(fig):
    """
    A grid of 2x2 images. Each image has its own colorbar.
    """

    grid = ImageGrid(fig, 144,  # similar to subplot(144)
                     nrows_ncols=(2, 2),
                     axes_pad=(0.45, 0.15),
                     label_mode="1",
                     share_all=True,
                     cbar_location="right",
                     cbar_mode="each",
                     cbar_size="7%",
                     cbar_pad="2%",
                     )
    Z, extent = get_demo_image()

    # Use a different colorbar range every time
    limits = ((0, 1), (-2, 2), (-1.7, 1.4), (-1.5, 1))
    for i in range(4):
        im = grid[i].imshow(Z, extent=extent, interpolation="nearest",
                            vmin=limits[i][0], vmax=limits[i][1])
        grid.cbar_axes[i].colorbar(im)

    for i, cax in enumerate(grid.cbar_axes):
        cax.set_yticks((limits[i][0], limits[i][1]))

    # This affects all axes because we set share_all = True.
    grid.axes_llc.set_xticks([-2, 0, 2])
    grid.axes_llc.set_yticks([-2, 0, 2]) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:32,代码来源:demo_axes_grid.py

示例11: show_images

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import ImageGrid [as 别名]
def show_images(H):
    # make a square grid
    num = H.shape[0]
    rows = int(np.ceil(np.sqrt(float(num))))

    fig = plt.figure(1, [10, 10])
    grid = ImageGrid(fig, 111, nrows_ncols=[rows, rows])

    for i in range(num):
        grid[i].axis('off')
        grid[i].imshow(H[i], cmap='Greys')

    # Turn any unused axes off
    for j in range(i, len(grid)):
        grid[j].axis('off') 
开发者ID:vithursant,项目名称:MagnetLoss-PyTorch,代码行数:17,代码来源:utils.py

示例12: save_imshow_grid

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import ImageGrid [as 别名]
def save_imshow_grid(images, logs_dir, filename, shape):
    """
    Plot images in a grid of a given shape.
    """
    fig = plt.figure(1)
    grid = ImageGrid(fig, 111, nrows_ncols=shape, axes_pad=0.05)

    size = shape[0] * shape[1]
    for i in trange(size, desc="Saving images"):
        grid[i].axis('off')
        grid[i].imshow(images[i])

    plt.savefig(os.path.join(logs_dir, filename)) 
开发者ID:shekkizh,项目名称:WassersteinGAN.tensorflow,代码行数:15,代码来源:utils.py

示例13: save_imshow_grid

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import ImageGrid [as 别名]
def save_imshow_grid(images, train_dir, filename, shape):
    """
    Plot images in a grid of a given shape.
    """
    fig = plt.figure(1)
    grid = ImageGrid(fig, 111, nrows_ncols=shape, axes_pad=0.05)

    size = shape[0] * shape[1]
    for i in trange(size, desc="Saving images"):
        grid[i].axis('off')
        grid[i].imshow(images[i])

    plt.savefig(os.path.join(train_dir, filename)) 
开发者ID:charliememory,项目名称:Pose-Guided-Person-Image-Generation,代码行数:15,代码来源:utils_wgan.py

示例14: plot_image_grid

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import ImageGrid [as 别名]
def plot_image_grid(images, num_rows, num_cols, save_path=None):
    """Plots images in a grid.

    Parameters
    ----------
    images : numpy.ndarray
        Images to display, with shape
        ``(num_rows * num_cols, num_channels, height, width)``.
    num_rows : int
        Number of rows for the image grid.
    num_cols : int
        Number of columns for the image grid.
    save_path : str, optional
        Where to save the image grid. Defaults to ``None``,
        which causes the grid to be displayed on screen.

    """
    figure = pyplot.figure()
    grid = ImageGrid(figure, 111, (num_rows, num_cols), axes_pad=0.1)

    for image, axis in zip(images, grid):
        axis.imshow(image.transpose(1, 2, 0), interpolation='nearest')
        axis.set_yticklabels(['' for _ in range(image.shape[1])])
        axis.set_xticklabels(['' for _ in range(image.shape[2])])
        axis.axis('off')

    if save_path is None:
        pyplot.show()
    else:
        pyplot.savefig(save_path, transparent=True, bbox_inches='tight',dpi=212)
        pyplot.close() 
开发者ID:ajbrock,项目名称:Neural-Photo-Editor,代码行数:33,代码来源:discgen_utils.py

示例15: imshow_grid

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import ImageGrid [as 别名]
def imshow_grid(images, shape=[2, 8], name='default', save=False):
    """Plot images in a grid of a given shape."""
    fig = plt.figure(1)
    grid = ImageGrid(fig, 111, nrows_ncols=shape, axes_pad=0.05)

    size = shape[0] * shape[1]
    for i in range(size):
        grid[i].axis('off')
        grid[i].imshow(images[i])  # The AxesGrid object work as a list of axes.

    if save:
        plt.savefig('reconstructed_images/' + str(name) + '.png')
        plt.clf()
    else:
        plt.show() 
开发者ID:ananyahjha93,项目名称:multi-level-vae,代码行数:17,代码来源:utils.py


注:本文中的mpl_toolkits.axes_grid1.ImageGrid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。