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


Python axes_grid1.AxesGrid方法代码示例

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


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

示例1: demo_bottom_cbar

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import AxesGrid [as 别名]
def demo_bottom_cbar(fig):
    """
    A grid of 2x2 images with a colorbar for each column.
    """
    grid = AxesGrid(fig, 121,  # similar to subplot(132)
                    nrows_ncols=(2, 2),
                    axes_pad=0.10,
                    share_all=True,
                    label_mode="1",
                    cbar_location="bottom",
                    cbar_mode="edge",
                    cbar_pad=0.25,
                    cbar_size="15%",
                    direction="column"
                    )

    Z, extent = get_demo_image()
    cmaps = [plt.get_cmap("autumn"), plt.get_cmap("summer")]
    for i in range(4):
        im = grid[i].imshow(Z, extent=extent, interpolation="nearest",
                            cmap=cmaps[i//2])
        if i % 2:
            cbar = grid.cbar_axes[i//2].colorbar(im)

    for cax in grid.cbar_axes:
        cax.toggle_label(True)
        cax.axis[cax.orientation].set_label("Bar")

    # 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,代码行数:33,代码来源:demo_edge_colorbar.py

示例2: demo_right_cbar

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

    grid = AxesGrid(F, 122,  # similar to subplot(122)
                    nrows_ncols=(2, 2),
                    axes_pad=0.10,
                    label_mode="1",
                    share_all=True,
                    cbar_location="right",
                    cbar_mode="edge",
                    cbar_size="7%",
                    cbar_pad="2%",
                    )
    Z, extent = get_demo_image()
    cmaps = [plt.get_cmap("spring"), plt.get_cmap("winter")]
    for i in range(4):
        im = grid[i].imshow(Z, extent=extent, interpolation="nearest",
                            cmap=cmaps[i//2])
        if i % 2:
            grid.cbar_axes[i//2].colorbar(im)

    for cax in grid.cbar_axes:
        cax.toggle_label(True)
        cax.axis[cax.orientation].set_label('Foo')

    # 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_edge_colorbar.py

示例3: accumulate_patches_into_heatmaps

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import AxesGrid [as 别名]
def accumulate_patches_into_heatmaps(self, all_test_output, outpath_prefix=''):
        outpath = "plots/%s_%s.png" % (outpath_prefix, path.splitext(path.basename(self.test_imagepath))[0])
        # http://matplotlib.org/examples/axes_grid/demo_axes_grid.html
        fig = plt.figure()
        grid = AxesGrid(fig, 143, # similar to subplot(143)
                    nrows_ncols = (1, 1))
        orig_img = imread(self.test_imagepath+'.png')
        grid[0].imshow(orig_img)
        grid = AxesGrid(fig, 144, # similar to subplot(144)
                    nrows_ncols = (2, 2),
                    axes_pad = 0.15,
                    label_mode = "1",
                    share_all = True,
                    cbar_location="right",
                    cbar_mode="each",
                    cbar_size="7%",
                    cbar_pad="2%",
                    )

        for klass in xrange(all_test_output.shape[1]):
            accumulator = numpy.zeros(self.ds.image_shape[:2])
            normalizer = numpy.zeros(self.ds.image_shape[:2])
            for n in xrange(self.num_patch_centers):
                i_start,i_end,j_start,j_end = self.nth_patch(n)

                accumulator[i_start:i_end, j_start:j_end] += all_test_output[n,klass]
                normalizer[i_start:i_end, j_start:j_end] += 1
            normalized_img = accumulator / normalizer
            im = grid[klass].imshow(normalized_img, interpolation="nearest", vmin=0, vmax=1)
            grid.cbar_axes[klass].colorbar(im)
        grid.axes_llc.set_xticks([])
        grid.axes_llc.set_yticks([])
        print("Saving figure as: %s" % outpath)
        plt.savefig(outpath, dpi=600, bbox_inches='tight') 
开发者ID:ilyakava,项目名称:kaggle-dr,代码行数:36,代码来源:plot_occluded_activations.py

示例4: plot_pathological_imgs

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import AxesGrid [as 别名]
def plot_pathological_imgs():
    fig = plt.figure()
    grid = AxesGrid(fig, 111, nrows_ncols = (1, 4))
    names = ['23050_right.png', '2468_left.png', '15450_left.png', '406_left.png']
    imgs = [imread(n) for n in names]
    [grid[i].imshow(imgs[i]) for i in range(len(imgs))]
    plt.axis('off')
    plt.savefig('out.png', dpi=300)

# figure of all kappa curves

# skips 1 lost result from above, is in diff order 
开发者ID:ilyakava,项目名称:kaggle-dr,代码行数:14,代码来源:figures.py

示例5: make_segmentation_triplets_for_paper

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import AxesGrid [as 别名]
def make_segmentation_triplets_for_paper(path, cls='Chair', export=False):

    image_types = ['/gt/', '/pred/', '/diff/']
    output_dir = path + '/triplet_images'

    if cls == 'all':
        hdf5_data_dir = os.path.join(BASE_DIR, './hdf5_data')
        all_obj_cat_file = os.path.join(hdf5_data_dir, 'all_object_categories.txt')
        fin = open(all_obj_cat_file, 'r')
        lines = [line.rstrip() for line in fin.readlines()]
        objnames = [line.split()[0] for line in lines]
        n_objects = len(objnames)
        filename = output_dir + '/' + 'all'
    else:
        n_objects = 1
        filename = output_dir + '/' + cls.title()
        objnames = [cls.title()]

    fig = plt.figure()
    ax = AxesGrid(fig, 111, nrows_ncols=(n_objects, 3), axes_pad=0.0)
    for i, obj in enumerate(objnames):
        cls_file_path = path+'/images/' + obj
        for j, img_type in enumerate(image_types):
            file_names = [os.path.join(cls_file_path + img_type, f) for f in os.listdir(cls_file_path + img_type)]
            file_names.sort()
            img = mpimg.imread(file_names[0])
            w = img.shape[1]
            h = img.shape[0]
            x0 = int(np.round(w * 0.25))
            y0 = int(np.round(h * 0.1))
            cropped_img = img[y0:y0+int(0.7*h),x0:x0+int(0.5*w),:]
            ax[3*i+j].axis('off')
            ax[3*i+j].imshow(cropped_img)

    #Visualize and export
    if not os.path.exists(output_dir):
        os.mkdir(output_dir)
    if export:
        plt.savefig(filename + '.png', format='png', bbox_inches='tight', dpi=600)
    else:
        plt.show() 
开发者ID:hkust-vgd,项目名称:scanobjectnn,代码行数:43,代码来源:visualization.py

示例6: plot_data

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import AxesGrid [as 别名]
def plot_data(path='./data', name='', output='.'):
    """
    Visualization using numpy arrays (written via MPI I/O) and json description

    Produces one png file per time-step, combine as movie via e.g.
      > ffmpeg -i data/name_%08d.png name.mp4

    Args:
        path (str): path to data files
        name (str): name of the simulation (expects data to be in data path)
        output (str): path to output
    """

    json_files = sorted(glob.glob(f'{path}/{name}_*.json'))
    data_files = sorted(glob.glob(f'{path}/{name}_*.dat'))

    for json_file, data_file in zip(json_files, data_files):
        with open(json_file, 'r') as fp:
            obj = json.load(fp)

        index = json_file.split('_')[-1].split('.')[0]
        print(f'Working on step {index}...')

        array = np.fromfile(data_file, dtype=obj['datatype'])
        array = array.reshape(obj['shape'], order='C')

        fig = plt.figure()

        grid = AxesGrid(fig, 111,
                        nrows_ncols=(1, 2),
                        axes_pad=0.15,
                        cbar_mode='single',
                        cbar_location='right',
                        cbar_pad=0.15
                        )

        im = grid[0].imshow(array[..., 0], vmin=0, vmax=1)
        im = grid[1].imshow(array[..., 1], vmin=0, vmax=1)

        grid[0].set_title(f"Field - Time: {obj['time']:6.4f}")
        grid[1].set_title(f"Temperature - Time: {obj['time']:6.4f}")

        grid[1].yaxis.set_visible(False)

        grid.cbar_axes[0].colorbar(im)

        plt.savefig(f'{output}/{name}_{index}.png', rasterized=True, bbox_inches='tight')
        plt.close() 
开发者ID:Parallel-in-Time,项目名称:pySDC,代码行数:50,代码来源:visualize_temp.py


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