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


Python Circle.set_linestyle方法代码示例

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


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

示例1: _add_patches

# 需要导入模块: from matplotlib.patches import Circle [as 别名]
# 或者: from matplotlib.patches.Circle import set_linestyle [as 别名]
    def _add_patches(self, df, method, fill, ax, diagonal=True):
        width, height = df.shape

        patches = []
        colors = []
        for x in range(width):
            for y in range(height):
                if fill == 'lower' and x > y:
                    continue
                elif fill == 'upper' and x < y:
                    continue
                if diagonal is False and x == y:
                    continue
                datum = (df.ix[x, y] + 1.) / 2.
                d = df.ix[x, y]
                d_abs = np.abs(d)
                #c = self.pvalues[x, y]
                rotate = -45 if d > 0 else +45
                #cmap = self.poscm if d >= 0 else self.negcm
                if method in ['ellipse', 'square', 'rectangle', 'color']:
                    if method == 'ellipse':
                        func = Ellipse
                        patch = func((x, y), width=1 * self.shrink,
                                     height=(self.shrink - d_abs * self.shrink), angle=rotate)
                    else:
                        func = Rectangle
                        w = h = d_abs * self.shrink
                        # FIXME shring must be <=1
                        offset = (1 - w) / 2.
                        if method == 'color':
                            w = 1
                            h = 1
                            offset = 0
                        patch = func((x + offset - .5, y + offset - .5), width=w,
                                     height=h, angle=0)
                    if self.edgecolor:
                        patch.set_edgecolor(self.edgecolor)
                    # patch.set_facecolor(cmap(d_abs))
                    colors.append(datum)
                    if d_abs > 0.05:
                        patch.set_linestyle('dotted')
                    # ax.add_artist(patch)
                    patches.append(patch)
                    # FIXME edgecolor is always printed
                elif method == 'circle':
                    patch = Circle((x, y), radius=d_abs * self.shrink / 2.)
                    if self.edgecolor:
                        patch.set_edgecolor(self.edgecolor)
                    # patch.set_facecolor(cmap(d_abs))
                    colors.append(datum)
                    if d_abs > 0.05:
                        patch.set_linestyle('dotted')
                    # ax.add_artist(patch)
                    patches.append(patch)
                elif method in ['number', 'text']:
                    if d < 0:
                        edgecolor = self.cm(-1.0)
                    elif d >= 0:
                        edgecolor = self.cm(1.0)
                    d_str = "{:.2f}".format(d).replace(
                        "0.", ".").replace(".00", "")
                    ax.text(x, y, d_str, color=edgecolor,
                            fontsize=self.fontsize, horizontalalignment='center',
                            weight='bold', alpha=max(0.5, d_abs),
                            withdash=False)
                elif method == 'pie':
                    S = 360 * d_abs
                    patch = [
                        Wedge((x, y), 1 * self.shrink / 2., -90, S - 90),
                        Wedge((x, y), 1 * self.shrink / 2., S - 90, 360 - 90),
                    ]
                    # patch[0].set_facecolor(cmap(d_abs))
                    # patch[1].set_facecolor('white')
                    colors.append(datum)
                    colors.append(0.5)
                    if self.edgecolor:
                        patch[0].set_edgecolor(self.edgecolor)
                        patch[1].set_edgecolor(self.edgecolor)

                    # ax.add_artist(patch[0])
                    # ax.add_artist(patch[1])
                    patches.append(patch[0])
                    patches.append(patch[1])
                else:
                    raise ValueError(
                        'Method for the symbols is not known. Use e.g, square, circle')

        if self.binarise_color:
            colors = [1 if color > 0.5 else -1 for color in colors]

        if len(patches):
            col1 = PatchCollection(
                patches, array=np.array(colors), cmap=self.cm)
            ax.add_collection(col1)

            self.collection = col1
开发者ID:GuillaumeSalha,项目名称:pyensae,代码行数:98,代码来源:corrplot.py

示例2: _add_patches

# 需要导入模块: from matplotlib.patches import Circle [as 别名]
# 或者: from matplotlib.patches.Circle import set_linestyle [as 别名]
    def _add_patches(self, df, method, fill, ax, diagonal=True):
        width, height = df.shape
        labels = (df.columns)

        patches = []
        colors = []
        for x in xrange(width):
            for y in xrange(height):
                if fill == 'lower' and x > y:
                    continue
                elif fill == 'upper' and x < y:
                    continue
                if diagonal is False and x==y:
                    continue
                datum = (df.ix[x, y] +1.)/2.
                d = df.ix[x, y]
                d_abs = np.abs(d)
                #c = self.pvalues[x, y]
                rotate = -45 if d > 0 else +45
                #cmap = self.poscm if d >= 0 else self.negcm
                if method in ['ellipse', 'square', 'rectangle', 'color']:
                    if method == 'ellipse':
                        func = Ellipse
                        patch = func((x, y), width=1 * self.shrink,
                                  height=(self.shrink - d_abs*self.shrink), angle=rotate)
                    else:
                        func = Rectangle
                        w = h = d_abs * self.shrink
                        #FIXME shring must be <=1
                        offset = (1-w)/2.
                        if method == 'color':
                            w = 1
                            h = 1
                            offset = 0
                        patch = func((x + offset-.5, y + offset-.5), width=w,
                                  height=h, angle=0)
                    if self.edgecolor:
                        patch.set_edgecolor(self.edgecolor)
                    #patch.set_facecolor(cmap(d_abs))
                    colors.append(datum)
                    if d_abs > 0.05:
                        patch.set_linestyle('dotted')
                    #ax.add_artist(patch)
                    patches.append(patch)
                    #FIXME edgecolor is always printed
                elif method=='circle':
                    patch = Circle((x, y), radius=d_abs*self.shrink/2.)
                    if self.edgecolor:
                        patch.set_edgecolor(self.edgecolor)
                    #patch.set_facecolor(cmap(d_abs))
                    colors.append(datum)
                    if d_abs > 0.05:
                        patch.set_linestyle('dotted')
                    #ax.add_artist(patch)
                    patches.append(patch)
                elif method in ['number', 'text']:
                    from easydev import precision
                    if d<0:
                        edgecolor = 'red'
                    elif d>=0:
                        edgecolor = 'blue'
                    ax.text(x,y, precision(d, 2), color=edgecolor,
                            fontsize=self.fontsize, horizontalalignment='center',
                            weight='bold', alpha=d_abs,
                            withdash=False)
                elif method == 'pie':
                    S = 360 * d_abs
                    patch = [
                        Wedge((x,y), 1*self.shrink/2., -90, S-90),
                        Wedge((x,y), 1*self.shrink/2., S-90, 360-90),
                        ]
                    #patch[0].set_facecolor(cmap(d_abs))
                    #patch[1].set_facecolor('white')
                    colors.append(datum)
                    colors.append(0.5)
                    if self.edgecolor:
                        patch[0].set_edgecolor(self.edgecolor)
                        patch[1].set_edgecolor(self.edgecolor)

                    #ax.add_artist(patch[0])
                    #ax.add_artist(patch[1])
                    patches.append(patch[0])                    
                    patches.append(patch[1])
        if len(patches):                    
            col1 = PatchCollection(patches, array=np.array(colors), cmap=self.cm)
            ax.add_collection(col1)

            self.collection = col1
开发者ID:cokelaer,项目名称:biokit,代码行数:90,代码来源:corrplot.py


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