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


Python RendererBase.draw_path_collection方法代码示例

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


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

示例1: draw_path_collection

# 需要导入模块: from matplotlib.backend_bases import RendererBase [as 别名]
# 或者: from matplotlib.backend_bases.RendererBase import draw_path_collection [as 别名]
    def draw_path_collection(self, gc, master_transform, paths, all_transforms,
                             offsets, offsetTrans, facecolors, edgecolors,
                             linewidths, linestyles, antialiaseds, urls,
                             offset_position):
        # Is the optimization worth it? Rough calculation:
        # cost of emitting a path in-line is
        #    (len_path + 5) * uses_per_path
        # cost of definition+use is
        #    (len_path + 3) + 9 * uses_per_path
        len_path = len(paths[0].vertices) if len(paths) > 0 else 0
        uses_per_path = self._iter_collection_uses_per_path(
            paths, all_transforms, offsets, facecolors, edgecolors)
        should_do_optimization = \
            len_path + 9 * uses_per_path + 3 < (len_path + 5) * uses_per_path
        if not should_do_optimization:
            return RendererBase.draw_path_collection(
                self, gc, master_transform, paths, all_transforms,
                offsets, offsetTrans, facecolors, edgecolors,
                linewidths, linestyles, antialiaseds, urls,
                offset_position)

        writer = self.writer
        path_codes = []
        writer.start('defs')
        for i, (path, transform) in enumerate(self._iter_collection_raw_paths(
            master_transform, paths, all_transforms)):
            transform = Affine2D(transform.get_matrix()).scale(1.0, -1.0)
            d = self._convert_path(path, transform, simplify=False)
            oid = 'C%x_%x_%s' % (self._path_collection_id, i,
                                  self._make_id('', d))
            writer.element('path', id=oid, d=d)
            path_codes.append(oid)
        writer.end('defs')

        for xo, yo, path_id, gc0, rgbFace in self._iter_collection(
            gc, master_transform, all_transforms, path_codes, offsets,
            offsetTrans, facecolors, edgecolors, linewidths, linestyles,
            antialiaseds, urls, offset_position):
            clipid = self._get_clip(gc0)
            url = gc0.get_url()
            if url is not None:
                writer.start('a', attrib={'xlink:href': url})
            if clipid is not None:
                writer.start('g', attrib={'clip-path': 'url(#%s)' % clipid})
            attrib = {
                'xlink:href': '#%s' % path_id,
                'x': short_float_fmt(xo),
                'y': short_float_fmt(self.height - yo),
                'style': self._get_style(gc0, rgbFace)
                }
            writer.element('use', attrib=attrib)
            if clipid is not None:
                writer.end('g')
            if url is not None:
                writer.end('a')

        self._path_collection_id += 1
开发者ID:4over7,项目名称:matplotlib,代码行数:59,代码来源:backend_svg.py

示例2: draw_path_collection

# 需要导入模块: from matplotlib.backend_bases import RendererBase [as 别名]
# 或者: from matplotlib.backend_bases.RendererBase import draw_path_collection [as 别名]
 def draw_path_collection(self, gc, master_transform, paths, all_transforms,
     offsets, offsetTrans, facecolors, edgecolors,
     linewidths, linestyles, antialiaseds, urls,
     offset_position):
     '''Draws a collection of paths selecting drawing properties from
        the lists *facecolors*, *edgecolors*, *linewidths*,
        *linestyles* and *antialiaseds*. *offsets* is a list of
        offsets to apply to each of the paths. The offsets in
        *offsets* are first transformed by *offsetTrans* before being
        applied.  *offset_position* may be either "screen" or "data"
        depending on the space that the offsets are in.
     '''
     len_path = len(paths[0].vertices) if len(paths) > 0 else 0
     uses_per_path = self._iter_collection_uses_per_path(
         paths, all_transforms, offsets, facecolors, edgecolors)
     # check whether an optimization is needed by calculating the cost of
     # generating and use a path with the cost of emitting a path in-line.
     should_do_optimization = \
         len_path + uses_per_path + 5 < len_path * uses_per_path
     if not should_do_optimization:
         return RendererBase.draw_path_collection(
             self, gc, master_transform, paths, all_transforms,
             offsets, offsetTrans, facecolors, edgecolors,
             linewidths, linestyles, antialiaseds, urls,
             offset_position)
     # Generate an array of unique paths with the respective transformations
     path_codes = []
     for i, (path, transform) in enumerate(self._iter_collection_raw_paths(
         master_transform, paths, all_transforms)):
         transform = Affine2D(transform.get_matrix()).scale(1.0, -1.0)
         if _mpl_ge_2_0:
             polygons = path.to_polygons(transform, closed_only=False)
         else:
             polygons = path.to_polygons(transform)
         path_codes.append(polygons)
     # Apply the styles and rgbFace to each one of the raw paths from
     # the list. Additionally a transformation is being applied to
     # translate each independent path
     for xo, yo, path_poly, gc0, rgbFace in self._iter_collection(
         gc, master_transform, all_transforms, path_codes, offsets,
         offsetTrans, facecolors, edgecolors, linewidths, linestyles,
         antialiaseds, urls, offset_position):
         list_canvas_instruction = self.get_path_instructions(gc0, path_poly,
                                 closed=True, rgbFace=rgbFace)
         for widget, instructions in list_canvas_instruction:
             widget.canvas.add(PushMatrix())
             widget.canvas.add(Translate(xo, yo))
             widget.canvas.add(instructions)
             widget.canvas.add(PopMatrix())
开发者ID:janssen,项目名称:garden.matplotlib,代码行数:51,代码来源:backend_kivy.py

示例3: draw_path_collection

# 需要导入模块: from matplotlib.backend_bases import RendererBase [as 别名]
# 或者: from matplotlib.backend_bases.RendererBase import draw_path_collection [as 别名]
    def draw_path_collection(self, gc, master_transform, paths, *args,
                             **kwargs):
        # We do a little shimmy so that all paths are drawn for each path
        # effect in turn. Essentially, we induce recursion (depth 1) which is
        # terminated once we have just a single path effect to work with.
        if len(self._path_effects) == 1:
            # Call the base path effect function - this uses the unoptimised
            # approach of calling "draw_path" multiple times.
            return RendererBase.draw_path_collection(self, gc,
                                                     master_transform, paths,
                                                     *args, **kwargs)

        for path_effect in self._path_effects:
            renderer = self.copy_with_path_effect([path_effect])
            # Recursively call this method, only next time we will only have
            # one path effect.
            renderer.draw_path_collection(gc, master_transform, paths,
                                          *args, **kwargs)
开发者ID:ethanhelfman,项目名称:InstaGet,代码行数:20,代码来源:patheffects.py


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