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


Python offsetbox.AnchoredOffsetbox方法代码示例

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


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

示例1: add_offsetboxes

# 需要导入模块: from matplotlib import offsetbox [as 别名]
# 或者: from matplotlib.offsetbox import AnchoredOffsetbox [as 别名]
def add_offsetboxes(ax, size=10, margin=.1, color='black'):
    """
    Surround ax with OffsetBoxes
    """
    m, mp = margin, 1+margin
    anchor_points = [(-m, -m), (-m, .5), (-m, mp),
                     (mp, .5), (.5, mp), (mp, mp),
                     (.5, -m), (mp, -m), (.5, -m)]
    for point in anchor_points:
        da = DrawingArea(size, size)
        background = Rectangle((0, 0), width=size,
                               height=size,
                               facecolor=color,
                               edgecolor='None',
                               linewidth=0,
                               antialiased=False)
        da.add_artist(background)

        anchored_box = AnchoredOffsetbox(
            loc='center',
            child=da,
            pad=0.,
            frameon=False,
            bbox_to_anchor=point,
            bbox_transform=ax.transAxes,
            borderpad=0.)
        ax.add_artist(anchored_box)
    return anchored_box 
开发者ID:holzschu,项目名称:python3_ios,代码行数:30,代码来源:test_tightlayout.py

示例2: test_tight_layout_offsetboxes

# 需要导入模块: from matplotlib import offsetbox [as 别名]
# 或者: from matplotlib.offsetbox import AnchoredOffsetbox [as 别名]
def test_tight_layout_offsetboxes():
    # 1.
    # - Create 4 subplots
    # - Plot a diagonal line on them
    # - Surround each plot with 7 boxes
    # - Use tight_layout
    # - See that the squares are included in the tight_layout
    #   and that the squares in the middle do not overlap
    #
    # 2.
    # - Make the squares around the right side axes invisible
    # - See that the invisible squares do not affect the
    #   tight_layout
    rows = cols = 2
    colors = ['red', 'blue', 'green', 'yellow']
    x = y = [0, 1]

    def _subplots():
        _, axs = plt.subplots(rows, cols)
        axs = axs.flat
        for ax, color in zip(axs, colors):
            ax.plot(x, y, color=color)
            add_offsetboxes(ax, 20, color=color)
        return axs

    # 1.
    axs = _subplots()
    plt.tight_layout()

    # 2.
    axs = _subplots()
    for ax in (axs[cols-1::rows]):
        for child in ax.get_children():
            if isinstance(child, AnchoredOffsetbox):
                child.set_visible(False)

    plt.tight_layout() 
开发者ID:holzschu,项目名称:python3_ios,代码行数:39,代码来源:test_tightlayout.py

示例3: add_offsetboxes

# 需要导入模块: from matplotlib import offsetbox [as 别名]
# 或者: from matplotlib.offsetbox import AnchoredOffsetbox [as 别名]
def add_offsetboxes(ax, size=10, margin=.1, color='black'):
    """
    Surround ax with OffsetBoxes
    """
    m, mp = margin, 1+margin
    anchor_points = [(-m, -m), (-m, .5), (-m, mp),
                     (mp, .5), (.5, mp), (mp, mp),
                     (.5, -m), (mp, -m), (.5, -m)]
    for point in anchor_points:
        da = DrawingArea(size, size)
        background = Rectangle((0, 0), width=size,
                               height=size,
                               facecolor=color,
                               edgecolor='None',
                               linewidth=0,
                               antialiased=False)
        da.add_artist(background)

        anchored_box = AnchoredOffsetbox(
            loc=10,
            child=da,
            pad=0.,
            frameon=False,
            bbox_to_anchor=point,
            bbox_transform=ax.transAxes,
            borderpad=0.)
        ax.add_artist(anchored_box)
    return anchored_box 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:30,代码来源:test_tightlayout.py


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