本文整理汇总了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
示例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