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


Python FancyBboxPatch.set_transform方法代码示例

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


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

示例1: _basic_outline

# 需要导入模块: from matplotlib.patches import FancyBboxPatch [as 别名]
# 或者: from matplotlib.patches.FancyBboxPatch import set_transform [as 别名]
 def _basic_outline(self, colors):
     if self.need != 0:
         #center = Circle(
         #    self.coords,
         #    self.r / float(20),
         #    color=color['lc'], zorder=4, facecolor=color['lc'], fill=True, alpha=self.alpha
         #)
         if self.layout_mode:
             border = Circle(
                 self.coords, 0.99 * self.r, color=colors['lc'], zorder=3, fill=False, edgecolor=colors['lc'],
                 alpha=self.alpha, linewidth=70 * self.scale
             )
             role_fill = Circle(
                 self.coords, self.r, color=self.role_color, zorder=4, facecolor=self.role_color, fill=True,
                 alpha=0.5 * self.alpha
             )
             self.basic_structure = [role_fill, border]
         else:
             border = Circle(
                 self.coords, self.r, color=colors['lc'], zorder=3, fill=False, edgecolor=colors['lc'],
                 alpha=self.alpha, linewidth=0.5
             )
             self.basic_structure = [border, ]#center]
     else:
         center = Circle(
             self.coords, self.r / self._transit_fraction, color=colors['lc'], zorder=4, facecolor=colors['lc'],
             fill=True, alpha=self.alpha
         )
         self.basic_structure = [center]
     if not self.functional:
         size = self.r if self.need != 0. else self.r / self._transit_fraction
         cross_bar = FancyBboxPatch(
             (0, 0), 2.4 * size, 0.2 * size,
             boxstyle="square,pad={}".format(0.05 * self.scale * self.label_scale),
             color=colors['ac'], alpha=min(1, 2 * self.alpha), zorder=6
         )
         rotator = Affine2D().rotate_deg(-40)
         corner_coords = (
             self.coords[0] - size,
             self.coords[1] + 0.7 * size
         )
         translator = Affine2D().translate(*corner_coords)
         transform = rotator + translator
         cross_bar.set_transform(transform)
         self.super_patch_collection.append(cross_bar)
开发者ID:j-i-l,项目名称:FlowVis,代码行数:47,代码来源:structure.py

示例2: _label

# 需要导入模块: from matplotlib.patches import FancyBboxPatch [as 别名]
# 或者: from matplotlib.patches.FancyBboxPatch import set_transform [as 别名]
    def _label(self, colors):
        """
        Method to create an edges label

        :return:
        """

        its_label = '{:g}'.format(abs(self.edge.capacity) if self.edge.capacity is not None else '')
        status_color = colors['bc']
        if not self.layout_mode:
            in_percent = int(round(100 * self.edge.flux / float(self.edge.capacity), 0))
            if in_percent < 100:
                status_color = colors['wc']
            its_label += '; {:g}%'.format(in_percent)
        # get the label coordinates based on self.segments (use the end of the first segment if several segments are
        # present, if it is a single, place the label half the way

        s_coords, e_coords = self.segments[0]
        edge_vec = Vec(s_coords, e_coords)
        start_vec = Vec(s_coords)
        # maybe always use the last part...
        if len(self.segments) == 1:  # single segment: place it half way
            part_way_vec = start_vec + self.label_position * edge_vec
            coords_label = part_way_vec.coords[:2]
        else:  # several segments: place label at the end of the first
            #half_way_vec = start_vec + 0.5 * edge_vec
            #coords_label = half_way_vec.coords[:2]
            coords_label = e_coords
        if self.with_label:
            self.labels = [
                # so far there is just a single label for an edge
                (
                    its_label,
                    coords_label,
                    {
                        'horizontalalignment': 'center',
                        'verticalalignment': 'center',
                        'size': self.scale * 200 * self.label_scale,
                        'color': colors['tc'],
                        'box_fc': status_color
                    }
                )
            ]
        else:
            self.labels = None
        # cross through the label if it is not functional
        if not self.functional:
            cross_bar = FancyBboxPatch(
                (0, 0), self.scale * self.label_scale, 0.07 * self.scale * self.label_scale,
                boxstyle="square,pad={}".format(0.05 * self.scale * self.label_scale),
                color=colors['ac'], alpha=min(1, 2 * self.alpha), zorder=6
            )
            rotator = Affine2D().rotate_deg(-45)
            corner_coords = (
                coords_label[0] - 0.4 * self.scale * self.label_scale,
                coords_label[1] + 0.3 * self.scale * self.label_scale
            )
            translator = Affine2D().translate(*corner_coords)
            transform = rotator + translator
            cross_bar.set_transform(transform)
            self.super_patch_collection.append(cross_bar)
开发者ID:j-i-l,项目名称:FlowVis,代码行数:63,代码来源:structure.py


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