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


Python axes_grid1.make_axes_locatable方法代码示例

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


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

示例1: __init__

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import make_axes_locatable [as 别名]
def __init__(self, winrates_df: pd.DataFrame) -> None:
        # make plot
        self.winrates = winrates_df
        self._fig = plt.figure()
        self._ax = self._fig.add_subplot(111)
        self._cax = self._ax.imshow(100 * np.array(self.winrates), cmap=cm.seismic, interpolation="none", vmin=0, vmax=100)
        x_names = self.winrates.columns
        self._ax.set_xticks(list(range(len(x_names))))
        self._ax.set_xticklabels(x_names, rotation=90, fontsize=7)  # , ha="left")
        y_names = self.winrates.index
        self._ax.set_yticks(list(range(len(y_names))))
        self._ax.set_yticklabels(y_names, rotation=45, fontsize=7)
        divider = make_axes_locatable(self._ax)
        cax = divider.append_axes("right", size="5%", pad=0.05)
        # self._fig.colorbar(im, cax=cax)
        self._fig.colorbar(self._cax, cax=cax)  # , orientation='horizontal')
        plt.tight_layout() 
开发者ID:facebookresearch,项目名称:nevergrad,代码行数:19,代码来源:plotting.py

示例2: make_square_add_cbar

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import make_axes_locatable [as 别名]
def make_square_add_cbar(ax, size=0.4, pad=0.1):
    """
    Make input axes square and return an appended axes to the right for
    a colorbar. Both axes resize together to fit figure automatically.
    Works with tight_layout().
    """
    divider = make_axes_locatable(ax)

    margin_size = axes_size.Fixed(size)
    pad_size = axes_size.Fixed(pad)
    xsizes = [pad_size, margin_size]
    ysizes = xsizes

    cax = divider.append_axes("right", size=margin_size, pad=pad_size)

    divider.set_horizontal([RemainderFixed(xsizes, ysizes, divider)] + xsizes)
    divider.set_vertical([RemainderFixed(xsizes, ysizes, divider)] + ysizes)
    return cax 
开发者ID:scikit-hep,项目名称:mplhep,代码行数:20,代码来源:plot.py

示例3: plot_heatmap

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import make_axes_locatable [as 别名]
def plot_heatmap(heatmap, fig=None, ax=None, legend_axis=None):
    if fig is None:
        fig = plt.gcf()
    if ax is None:
        ax = plt.gca()
    p, x, y, _ = heatmap
    im = ax.imshow(
        np.swapaxes(p, 0, 1),  # imshow uses first axis as y-axis
        extent=[x.min(), x.max(), y.min(), y.max()],
        cmap=plt.get_cmap('plasma'),
        interpolation='nearest',
        aspect='auto',
        origin='bottom',  # <-- Important! By default top left is (0, 0)
    )
    if legend_axis is None:
        divider = make_axes_locatable(ax)
        legend_axis = divider.append_axes('right', size='5%', pad=0.05)
    fig.colorbar(im, cax=legend_axis, orientation='vertical')
    return im, legend_axis 
开发者ID:snasiriany,项目名称:leap,代码行数:21,代码来源:visualization_util.py

示例4: plot_vector_field

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import make_axes_locatable [as 别名]
def plot_vector_field(fig, ax, vector_field, skip_rate=1):
    skip = (slice(None, None, skip_rate), slice(None, None, skip_rate))
    p, dx, dy, x, y, _ = vector_field
    im = ax.imshow(
        np.swapaxes(p, 0, 1),  # imshow uses first axis as y-axis
        extent=[x.min(), x.max(), y.min(), y.max()],
        cmap=plt.get_cmap('plasma'),
        interpolation='nearest',
        aspect='auto',
        origin='bottom',  # <-- Important! By default top left is (0, 0)
    )
    x, y = np.meshgrid(x, y)
    ax.quiver(x[skip], y[skip], dx[skip], dy[skip])

    divider = make_axes_locatable(ax)
    cax = divider.append_axes('right', size='5%', pad=0.05)
    fig.colorbar(im, cax=cax, orientation='vertical') 
开发者ID:snasiriany,项目名称:leap,代码行数:19,代码来源:visualization_util.py

示例5: _process_metric

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import make_axes_locatable [as 别名]
def _process_metric(self, ax, metric):
        if not metric.data.size:
            ax.tick_params(colors=(0, 0, 0, 0))
            ax.set_axis_bgcolor(cm.get_cmap('viridis')(0))
            divider = make_axes_locatable(ax)
            divider.append_axes('right', size='7%', pad=0.1).axis('off')
            return
        domain = self._domain(metric)
        categorical = self._is_categorical(metric.data)
        if metric.data.shape[1] == 1 and not categorical:
            self._plot_scalar(ax, domain, metric.data[:, 0])
        elif metric.data.shape[1] == 1:
            indices = metric.data[:, 0].astype(int)
            min_, max_ = indices.min(), indices.max()
            count = np.eye(max_ - min_ + 1)[indices - min_]
            self._plot_distribution(ax, domain, count)
        elif metric.data.shape[1] > 1:
            self._plot_counts(ax, domain, metric.data) 
开发者ID:danijar,项目名称:mindpark,代码行数:20,代码来源:metrics.py

示例6: ex3

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import make_axes_locatable [as 别名]
def ex3():

        fig = plt.figure(3)
        ax1 = plt.axes([0, 0, 1, 1])
        divider = make_axes_locatable(ax1)

        ax2 = divider.new_horizontal("100%", pad=0.3, sharey=ax1)
        ax2.tick_params(labelleft=False)
        fig.add_axes(ax2)

        divider.add_auto_adjustable_area(use_axes=[ax1], pad=0.1,
                                         adjust_dirs=["left"])
        divider.add_auto_adjustable_area(use_axes=[ax2], pad=0.1,
                                         adjust_dirs=["right"])
        divider.add_auto_adjustable_area(use_axes=[ax1, ax2], pad=0.1,
                                         adjust_dirs=["top", "bottom"])

        ax1.set_yticks([0.5])
        ax1.set_yticklabels(["very long label"])

        ax2.set_title("Title")
        ax2.set_xlabel("X - Label") 
开发者ID:holzschu,项目名称:python3_ios,代码行数:24,代码来源:make_room_for_ylabel_using_axesgrid.py

示例7: plot_cells

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import make_axes_locatable [as 别名]
def plot_cells(state_cells, walls_inf, i):
    """
    plot the actual state of the cells. we need to make 'bad' walls to better visualize the cells
    :param state_cells: state of the cells
    :param walls_inf: walls for visualisation purposes
    :param i: index for figures
    """
    walls_inf = walls_inf * np.Inf
    tmp_cells = np.vstack((walls_inf, state_cells))
    tmp_cells = np.vstack((tmp_cells, walls_inf))
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.cla()
    cmap = plt.get_cmap('gray')
    cmap.set_bad(color='k', alpha=0.8)
    im = ax.imshow(tmp_cells, cmap=cmap, vmin=0, vmax=1, interpolation='nearest')
    divider = make_axes_locatable(ax)
    cax = divider.append_axes('right', size='1%', pad=0.1)
    plt.colorbar(im, cax=cax, ticks=[0, 1])
    ax.set_axis_off()
    num = sum(state_cells)
    text = "t: %3.3d | n: %d\n" % (i, num)
    plt.title("%20s" % text, rotation=0, fontsize=10, verticalalignment='bottom')
    figure_name = os.path.join('pngs', 'peds%.3d.png' % i)
    plt.savefig(figure_name, dpi=100, facecolor='lightgray') 
开发者ID:chraibi,项目名称:cellular_automata,代码行数:27,代码来源:asep_slow.py

示例8: drawplot

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import make_axes_locatable [as 别名]
def drawplot(self, img, img_name, itr, index, bodyparts, cmap, keep_view=False):
        xlim = self.axes.get_xlim()
        ylim = self.axes.get_ylim()
        self.axes.clear()
        #        im = cv2.imread(img)
        # convert the image to RGB as you are showing the image with matplotlib
        im = cv2.imread(img)[..., ::-1]
        ax = self.axes.imshow(im, cmap=cmap)
        self.orig_xlim = self.axes.get_xlim()
        self.orig_ylim = self.axes.get_ylim()
        #        divider = make_axes_locatable(self.axes)
        #        colorIndex = np.linspace(np.min(im),np.max(im),len(bodyparts))
        #        cax = divider.append_axes("right", size="5%", pad=0.05)
        #        cbar = self.figure.colorbar(ax, cax=cax,spacing='proportional', ticks=colorIndex)
        #        cbar.set_ticklabels(bodyparts[::-1])
        self.axes.set_title(str(str(itr) + "/" + str(len(index) - 1) + " " + img_name))
        #        self.figure.canvas.draw()
        if keep_view:
            self.axes.set_xlim(xlim)
            self.axes.set_ylim(ylim)
        self.toolbar = NavigationToolbar(self.canvas)
        return (self.figure, self.axes, self.canvas, self.toolbar, ax) 
开发者ID:DeepLabCut,项目名称:DeepLabCut,代码行数:24,代码来源:multiple_individuals_labeling_toolbox.py

示例9: drawplot

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import make_axes_locatable [as 别名]
def drawplot(self, img, img_name, itr, index, bodyparts, cmap, keep_view=False):
        xlim = self.axes.get_xlim()
        ylim = self.axes.get_ylim()
        self.axes.clear()

        # convert the image to RGB as you are showing the image with matplotlib
        im = cv2.imread(img)[..., ::-1]
        ax = self.axes.imshow(im, cmap=cmap)
        self.orig_xlim = self.axes.get_xlim()
        self.orig_ylim = self.axes.get_ylim()
        divider = make_axes_locatable(self.axes)
        colorIndex = np.linspace(np.min(im), np.max(im), len(bodyparts))
        cax = divider.append_axes("right", size="5%", pad=0.05)
        cbar = self.figure.colorbar(
            ax, cax=cax, spacing="proportional", ticks=colorIndex
        )
        cbar.set_ticklabels(bodyparts[::-1])
        self.axes.set_title(str(str(itr) + "/" + str(len(index) - 1) + " " + img_name))
        if keep_view:
            self.axes.set_xlim(xlim)
            self.axes.set_ylim(ylim)
        self.toolbar = NavigationToolbar(self.canvas)
        return (self.figure, self.axes, self.canvas, self.toolbar) 
开发者ID:DeepLabCut,项目名称:DeepLabCut,代码行数:25,代码来源:labeling_toolbox.py

示例10: show_word_score_heatmap

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import make_axes_locatable [as 别名]
def show_word_score_heatmap(score_tensor, x_ticks, y_ticks, figsize=(3, 8)):
    # to make colorbar a proper size w.r.t the image
    def colorbar(mappable):
        ax = mappable.axes
        fig = ax.figure
        divider = make_axes_locatable(ax)
        cax = divider.append_axes("right", size="10%", pad=0.1)
        return fig.colorbar(mappable, cax=cax)

    mpl.rcParams['font.sans-serif'] = ['simhei']
    mpl.rcParams['axes.unicode_minus'] = False

    fig, ax = plt.subplots(nrows=1, ncols=1, figsize=figsize)

    img = ax.matshow(score_tensor.numpy())

    plt.xticks(range(score_tensor.size(1)), x_ticks, fontsize=14)
    plt.yticks(range(score_tensor.size(0)), y_ticks, fontsize=14)

    colorbar(img)

    ax.set_aspect('auto')
    plt.show() 
开发者ID:thunlp,项目名称:DIAG-NRE,代码行数:25,代码来源:utils.py

示例11: plot_image

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import make_axes_locatable [as 别名]
def plot_image(data, vmin=None, vmax=None, colorbar=True, cmap="gray"):
    """
    Plot image data, such as RTM images or FWI gradients.

    Parameters
    ----------
    data : ndarray
        Image data to plot.
    cmap : str
        Choice of colormap. Defaults to gray scale for images as a
        seismic convention.
    """
    plot = plt.imshow(np.transpose(data),
                      vmin=vmin or 0.9 * np.min(data),
                      vmax=vmax or 1.1 * np.max(data),
                      cmap=cmap)

    # Create aligned colorbar on the right
    if colorbar:
        ax = plt.gca()
        divider = make_axes_locatable(ax)
        cax = divider.append_axes("right", size="5%", pad=0.05)
        plt.colorbar(plot, cax=cax)
    plt.show() 
开发者ID:devitocodes,项目名称:devito,代码行数:26,代码来源:plotting.py

示例12: plot_similarity_matrix

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import make_axes_locatable [as 别名]
def plot_similarity_matrix(matrix, labels_a=None, labels_b=None, ax: plt.Axes=None, title=""):
    if ax is None:
        _, ax = plt.subplots()
    fig = plt.gcf()
        
    img = ax.matshow(matrix, extent=(-0.5, matrix.shape[0] - 0.5, 
                                     -0.5, matrix.shape[1] - 0.5))

    ax.xaxis.set_ticks_position("bottom")
    if labels_a is not None:
        ax.set_xticks(range(len(labels_a)))
        ax.set_xticklabels(labels_a, rotation=90)
    if labels_b is not None:
        ax.set_yticks(range(len(labels_b)))
        ax.set_yticklabels(labels_b[::-1])  # Upper origin -> reverse y axis
    ax.set_title(title)

    cax = make_axes_locatable(ax).append_axes("right", size="5%", pad=0.15)
    fig.colorbar(img, cax=cax, ticks=np.linspace(0.4, 1, 7))
    img.set_clim(0.4, 1)
    img.set_cmap("inferno")
    
    return ax 
开发者ID:resemble-ai,项目名称:Resemblyzer,代码行数:25,代码来源:demo_utils.py

示例13: plot2D_correlation

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import make_axes_locatable [as 别名]
def plot2D_correlation(self, plotFig, plotAx, data_x, data_y, corr):

    plotAx.cla() #clear the figure
    plotAx.patch.set_facecolor('none') #remove figure background

    try:
        plotFig.delaxes(plotFig.axes[1])
    except:
        pass

    #plotAx.mappable = plotAx.contourf(data_x, data_y, corr, np.linspace(0, 1, 9), cmap = 'Spectral', extend='min', spacing='proportional')
    plotAx.mappable = plotAx.imshow(corr, cmap = 'RdBu')
    plotAx.mappable.axes.xaxis.set_ticklabels([])
    plotAx.mappable.axes.yaxis.set_ticklabels([])
    plotAx.invert_yaxis()

    #colorbar display
    divider = make_axes_locatable(plotAx)
    plotAx.cax = divider.append_axes('right', size='5%', pad='1%')
    plotAx.cbar = plotFig.colorbar(plotAx.mappable, cax=plotAx.cax, extend='min')
    plotAx.cbar.ax.tick_params(labelsize=7)
    labels = np.linspace(0, 1, 11)
    ticks = np.linspace(-0.1, 0.1, 11)
    plotAx.cbar.set_ticks(ticks)
    plotAx.cbar.set_ticklabels(labels) 
开发者ID:ChrisEberl,项目名称:Python_DIC,代码行数:27,代码来源:plot2D.py

示例14: test_plain_axes

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import make_axes_locatable [as 别名]
def test_plain_axes(self):

        # supplied ax itself is a SubplotAxes, but figure contains also
        # a plain Axes object (GH11556)
        fig, ax = self.plt.subplots()
        fig.add_axes([0.2, 0.2, 0.2, 0.2])
        Series(rand(10)).plot(ax=ax)

        # suppliad ax itself is a plain Axes, but because the cmap keyword
        # a new ax is created for the colorbar -> also multiples axes (GH11520)
        df = DataFrame({'a': randn(8), 'b': randn(8)})
        fig = self.plt.figure()
        ax = fig.add_axes((0, 0, 1, 1))
        df.plot(kind='scatter', ax=ax, x='a', y='b', c='a', cmap='hsv')

        # other examples
        fig, ax = self.plt.subplots()
        from mpl_toolkits.axes_grid1 import make_axes_locatable
        divider = make_axes_locatable(ax)
        cax = divider.append_axes("right", size="5%", pad=0.05)
        Series(rand(10)).plot(ax=ax)
        Series(rand(10)).plot(ax=cax)

        fig, ax = self.plt.subplots()
        from mpl_toolkits.axes_grid1.inset_locator import inset_axes
        iax = inset_axes(ax, width="30%", height=1., loc=3)
        Series(rand(10)).plot(ax=ax)
        Series(rand(10)).plot(ax=iax) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:30,代码来源:test_frame.py

示例15: plot_line_power

# 需要导入模块: from mpl_toolkits import axes_grid1 [as 别名]
# 或者: from mpl_toolkits.axes_grid1 import make_axes_locatable [as 别名]
def plot_line_power(obj, results, hour, ax=None):
    '''
    obj: case or network
    '''

    if ax is None:
        fig, ax = plt.subplots(1, 1, figsize=(16, 10))
        ax.axis('off')

    case, network = _return_case_network(obj)

    network.draw_buses(ax=ax)
    network.draw_loads(ax=ax)
    network.draw_generators(ax=ax)
    network.draw_connections('gen_to_bus', ax=ax)
    network.draw_connections('load_to_bus', ax=ax)

    edgelist, edge_color, edge_width, edge_labels = _generate_edges(results, case, hour)
    branches = network.draw_branches(ax=ax, edgelist=edgelist, edge_color=edge_color, width=edge_width, edge_labels=edge_labels)

    divider = make_axes_locatable(ax)
    cax = divider.append_axes('right', size='5%', pad=0.05)
    cb = plt.colorbar(branches, cax=cax, orientation='vertical')
    cax.yaxis.set_label_position('left')
    cax.yaxis.set_ticks_position('left')
    cb.set_label('Loading Factor')

    return ax 
开发者ID:power-system-simulation-toolbox,项目名称:psst,代码行数:30,代码来源:network.py


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