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


Python offsetbox.AnchoredText方法代码示例

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


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

示例1: _draw_text_bbox

# 需要导入模块: from matplotlib import offsetbox [as 别名]
# 或者: from matplotlib.offsetbox import AnchoredText [as 别名]
def _draw_text_bbox(ax):
    """
    Draw legend() and fetch it's bbox
    """
    fig = ax.figure
    textboxes = []
    for k in ax.get_children():
        if type(k) == AnchoredText:
            textboxes.append(k)

    if len(textboxes) > 1:
        print("Warning: More than one textbox found")
        for box in textboxes:
            if box.loc in [1, 2]:
                bbox = box.get_tightbbox(fig.canvas.renderer)
    else:
        bbox = textboxes[0].get_tightbbox(fig.canvas.renderer)

    return bbox 
开发者ID:scikit-hep,项目名称:mplhep,代码行数:21,代码来源:plot.py

示例2: draw_text

# 需要导入模块: from matplotlib import offsetbox [as 别名]
# 或者: from matplotlib.offsetbox import AnchoredText [as 别名]
def draw_text(ax):
    """
    Draw two text-boxes, anchored by different corners to the upper-left
    corner of the figure.
    """
    from matplotlib.offsetbox import AnchoredText
    at = AnchoredText("Figure 1a",
                      loc='upper left', prop=dict(size=8), frameon=True,
                      )
    at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
    ax.add_artist(at)

    at2 = AnchoredText("Figure 1(b)",
                       loc='lower left', prop=dict(size=8), frameon=True,
                       bbox_to_anchor=(0., 1.),
                       bbox_transform=ax.transAxes
                       )
    at2.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
    ax.add_artist(at2) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:21,代码来源:simple_anchored_artists.py

示例3: _subplot_label

# 需要导入模块: from matplotlib import offsetbox [as 别名]
# 或者: from matplotlib.offsetbox import AnchoredText [as 别名]
def _subplot_label(self, axis):
        layout_num = self.layout_num if self.subplot else 1
        if self.sublabel_format and not self.adjoined and layout_num > 0:
            from matplotlib.offsetbox import AnchoredText
            labels = {}
            if '{Alpha}' in self.sublabel_format:
                labels['Alpha'] = int_to_alpha(layout_num-1)
            elif '{alpha}' in self.sublabel_format:
                labels['alpha'] = int_to_alpha(layout_num-1, upper=False)
            elif '{numeric}' in self.sublabel_format:
                labels['numeric'] = self.layout_num
            elif '{Roman}' in self.sublabel_format:
                labels['Roman'] = int_to_roman(layout_num)
            elif '{roman}' in self.sublabel_format:
                labels['roman'] = int_to_roman(layout_num).lower()
            at = AnchoredText(self.sublabel_format.format(**labels), loc=3,
                              bbox_to_anchor=self.sublabel_position, frameon=False,
                              prop=dict(size=self.sublabel_size, weight='bold'),
                              bbox_transform=axis.transAxes)
            at.patch.set_visible(False)
            axis.add_artist(at)
            sublabel = at.txt.get_children()[0]
            self.handles['sublabel'] = sublabel
            self.handles['bbox_extra_artists'] += [sublabel] 
开发者ID:holoviz,项目名称:holoviews,代码行数:26,代码来源:plot.py

示例4: add_anchored

# 需要导入模块: from matplotlib import offsetbox [as 别名]
# 或者: from matplotlib.offsetbox import AnchoredText [as 别名]
def add_anchored(*args, **kwargs):
    """
    Add text at a particular location in the current Axes

    Args:
        s (string): text
        loc (string): location code
        pad (float [optional]): pad between the text and the frame 
            as fraction of the font size
        borderpad (float [optional]): pad between the frame and the axes (or *bbox_to_anchor*)
        prop (matplotlib.font_manager.FontProperties): font properties
    """

    bbox = {}
    if 'bbox' in kwargs:
        bbox = kwargs.pop('bbox')
    at = AnchoredText(*args, **kwargs)
    if len(bbox.keys()) > 0:
        pl.setp(at.patch, **bbox)

    ax = pl.gca()
    ax.add_artist(at) 
开发者ID:California-Planet-Search,项目名称:radvel,代码行数:24,代码来源:__init__.py

示例5: _add_inner_title

# 需要导入模块: from matplotlib import offsetbox [as 别名]
# 或者: from matplotlib.offsetbox import AnchoredText [as 别名]
def _add_inner_title(self, ax, title, loc, size=None, **kwargs):
        if size is None:
            size = dict(size=pp.rcParams['legend.fontsize'])
        at = AnchoredText(
            title, loc=loc, prop=size, pad=0., borderpad=0.5, frameon=False,
            **kwargs
        )
        at.set_zorder(200)
        ax.add_artist(at)
        at.txt._text.set_path_effects(
            [withStroke(foreground="w", linewidth=3)]
        )
        return at 
开发者ID:jantman,项目名称:python-wifi-survey-heatmap,代码行数:15,代码来源:heatmap.py

示例6: yscale_text

# 需要导入模块: from matplotlib import offsetbox [as 别名]
# 或者: from matplotlib.offsetbox import AnchoredText [as 别名]
def yscale_text(ax=None):
    """
    Automatically scale y-axis up to fit AnchoredText
    """
    if ax is None:
        ax = plt.gca()

    while overlap(ax, _draw_text_bbox(ax)) > 0:
        ax.set_ylim(ax.get_ylim()[0], ax.get_ylim()[-1] * 1.1)
        ax.figure.canvas.draw()
    return ax 
开发者ID:scikit-hep,项目名称:mplhep,代码行数:13,代码来源:plot.py

示例7: add_inner_title

# 需要导入模块: from matplotlib import offsetbox [as 别名]
# 或者: from matplotlib.offsetbox import AnchoredText [as 别名]
def add_inner_title(ax, title, loc, size=None, **kwargs):
    from matplotlib.offsetbox import AnchoredText
    from matplotlib.patheffects import withStroke
    if size is None:
        size = dict(size=plt.rcParams['legend.fontsize'])
    at = AnchoredText(title, loc=loc, prop=size,
                      pad=0., borderpad=0.5,
                      frameon=False, **kwargs)
    ax.add_artist(at)
    at.txt._text.set_path_effects([withStroke(foreground="w", linewidth=3)])
    return at 
开发者ID:holzschu,项目名称:python3_ios,代码行数:13,代码来源:demo_axes_grid2.py

示例8: _

# 需要导入模块: from matplotlib import offsetbox [as 别名]
# 或者: from matplotlib.offsetbox import AnchoredText [as 别名]
def _(self, index, ax, kind='vawt', cm='seismic', ptype='seis'):
        data = self.data(index)
        handle = None
        if kind == 'vawt':
            wiggles(data.T, wiggleInterval=1, ax=ax)
        elif kind == 'img':
            handle = img(data.T,
                         extent=[
                             self.startCrline, self.endCrline,
                             self.startDepth, self.endDepth],
                         ax=ax, cm=cm, ptype=ptype)
            ax.invert_yaxis()
        else:
            pass
        ax.get_figure().suptitle('In-line Section: {}'.format(index.value))
        from matplotlib.offsetbox import AnchoredText
        z_text = AnchoredText(
            r"$\downarrow$Z",
            loc=2, prop=dict(size=10), frameon=False,
            bbox_to_anchor=(0., 0.),
            bbox_transform=ax.transAxes)
        ax.add_artist(z_text)
        inline_text = AnchoredText(
            r"Cross-line $\rightarrow$ ",
            loc=1, prop=dict(size=10), frameon=False,
            bbox_to_anchor=(1., 0.),
            bbox_transform=ax.transAxes)
        ax.add_artist(inline_text)

        return handle 
开发者ID:whimian,项目名称:pyGeoPressure,代码行数:32,代码来源:seisegy.py

示例9: display

# 需要导入模块: from matplotlib import offsetbox [as 别名]
# 或者: from matplotlib.offsetbox import AnchoredText [as 别名]
def display(annotation, meta=True, **kwargs):
    '''Visualize a jams annotation through mir_eval

    Parameters
    ----------
    annotation : jams.Annotation
        The annotation to display

    meta : bool
        If `True`, include annotation metadata in the figure

    kwargs
        Additional keyword arguments to mir_eval.display functions

    Returns
    -------
    ax
        Axis handles for the new display

    Raises
    ------
    NamespaceError
        If the annotation cannot be visualized
    '''

    for namespace, func in six.iteritems(VIZ_MAPPING):
        try:
            ann = coerce_annotation(annotation, namespace)

            axes = func(ann, **kwargs)

            # Title should correspond to original namespace, not the coerced version
            axes.set_title(annotation.namespace)
            if meta:
                description = pprint_jobject(annotation.annotation_metadata, indent=2)

                anchored_box = AnchoredText(description.strip('\n'),
                                            loc=2,
                                            frameon=True,
                                            bbox_to_anchor=(1.02, 1.0),
                                            bbox_transform=axes.transAxes,
                                            borderpad=0.0)
                axes.add_artist(anchored_box)

                axes.figure.subplots_adjust(right=0.8)

            return axes
        except NamespaceError:
            pass

    raise NamespaceError('Unable to visualize annotation of namespace="{:s}"'
                         .format(annotation.namespace)) 
开发者ID:marl,项目名称:jams,代码行数:54,代码来源:display.py


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