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


Python PathEffectRenderer.draw_text方法代码示例

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


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

示例1: draw

# 需要导入模块: from matplotlib.patheffects import PathEffectRenderer [as 别名]
# 或者: from matplotlib.patheffects.PathEffectRenderer import draw_text [as 别名]
    def draw(self, renderer):
        """
        Draws the :class:`Text` object to the given *renderer*.
        """
        if renderer is not None:
            self._renderer = renderer
        if not self.get_visible():
            return
        if self.text.strip() == '':
            return

        renderer.open_group('text', self.gid)

        bbox, info, descent = self._get_layout(renderer)
        trans = self.transform

        # don't use self.get_position here, which refers to text position
        # in Text, and dash position in TextWithDash:
        posx = float(self.convert_xunits(self._x))
        posy = float(self.convert_yunits(self._y))

        posx, posy = trans.transform_point((posx, posy))
        canvasw, canvash = renderer.get_canvas_width_height()

        # draw the FancyBboxPatch
        if self._bbox_patch:
            self._draw_bbox(renderer, posx, posy)

        if self.style == None:
            self._defaultStyle()

        if self.style.clip_path is None and self.style.clip_rectangle is None:
            self._set_gc_clip(self.style)

        if self._bbox:
            bbox_artist(self, renderer, self._bbox)
        angle = self.get_rotation()

        for line, wh, x, y in info:
            if not np.isfinite(x) or not np.isfinite(y):
                continue

            mtext = self if len(info) == 1 else None
            x = x + posx
            y = y + posy
            if renderer.flipy():
                y = canvash - y
            clean_line, ismath = self.is_math_text(line)

            if self.get_path_effects():
                from matplotlib.patheffects import PathEffectRenderer
                renderer = PathEffectRenderer(self.get_path_effects(),
                                              renderer)

            if rcParams['text.usetex']:
                renderer.draw_tex(self.style, x, y, clean_line,
                                  self.font, angle, mtext=mtext)
            else:
                renderer.draw_text(self.style, x, y, clean_line,
                                   self.font, angle,
                                   ismath=ismath, mtext=mtext)

        self.style.restore()
        renderer.close_group('text')
开发者ID:JamesRamm,项目名称:mpl_experiment,代码行数:66,代码来源:lines_style.py


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