本文整理汇总了Python中matplotlib.patches.Rectangle.set_hatch方法的典型用法代码示例。如果您正苦于以下问题:Python Rectangle.set_hatch方法的具体用法?Python Rectangle.set_hatch怎么用?Python Rectangle.set_hatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.patches.Rectangle
的用法示例。
在下文中一共展示了Rectangle.set_hatch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addItem
# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_hatch [as 别名]
def addItem(self, x, y, legend, shape, color, fill, overlay, z):
xView = numpy.array(x, copy=False)
yView = numpy.array(y, copy=False)
if shape == "line":
item = self.ax.plot(x, y, label=legend, color=color,
linestyle='-', marker=None)[0]
elif shape == "hline":
if hasattr(y, "__len__"):
y = y[-1]
item = self.ax.axhline(y, label=legend, color=color)
elif shape == "vline":
if hasattr(x, "__len__"):
x = x[-1]
item = self.ax.axvline(x, label=legend, color=color)
elif shape == 'rectangle':
xMin = numpy.nanmin(xView)
xMax = numpy.nanmax(xView)
yMin = numpy.nanmin(yView)
yMax = numpy.nanmax(yView)
w = xMax - xMin
h = yMax - yMin
item = Rectangle(xy=(xMin, yMin),
width=w,
height=h,
fill=False,
color=color)
if fill:
item.set_hatch('.')
self.ax.add_patch(item)
elif shape in ('polygon', 'polylines'):
xView = xView.reshape(1, -1)
yView = yView.reshape(1, -1)
item = Polygon(numpy.vstack((xView, yView)).T,
closed=(shape == 'polygon'),
fill=False,
label=legend,
color=color)
if fill and shape == 'polygon':
item.set_hatch('/')
self.ax.add_patch(item)
else:
raise NotImplementedError("Unsupported item shape %s" % shape)
item.set_zorder(z)
if overlay:
item.set_animated(True)
self._overlays.add(item)
return item
示例2: addItem
# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_hatch [as 别名]
def addItem(self, x, y, legend, shape, color, fill, overlay, z,
linestyle, linewidth, linebgcolor):
if (linebgcolor is not None and
shape not in ('rectangle', 'polygon', 'polylines')):
_logger.warning(
'linebgcolor not implemented for %s with matplotlib backend',
shape)
xView = numpy.array(x, copy=False)
yView = numpy.array(y, copy=False)
linestyle = normalize_linestyle(linestyle)
if shape == "line":
item = self.ax.plot(x, y, label=legend, color=color,
linestyle=linestyle, linewidth=linewidth,
marker=None)[0]
elif shape == "hline":
if hasattr(y, "__len__"):
y = y[-1]
item = self.ax.axhline(y, label=legend, color=color,
linestyle=linestyle, linewidth=linewidth)
elif shape == "vline":
if hasattr(x, "__len__"):
x = x[-1]
item = self.ax.axvline(x, label=legend, color=color,
linestyle=linestyle, linewidth=linewidth)
elif shape == 'rectangle':
xMin = numpy.nanmin(xView)
xMax = numpy.nanmax(xView)
yMin = numpy.nanmin(yView)
yMax = numpy.nanmax(yView)
w = xMax - xMin
h = yMax - yMin
item = Rectangle(xy=(xMin, yMin),
width=w,
height=h,
fill=False,
color=color,
linestyle=linestyle,
linewidth=linewidth)
if fill:
item.set_hatch('.')
if linestyle != "solid" and linebgcolor is not None:
item = _DoubleColoredLinePatch(item)
item.linebgcolor = linebgcolor
self.ax.add_patch(item)
elif shape in ('polygon', 'polylines'):
points = numpy.array((xView, yView)).T
if shape == 'polygon':
closed = True
else: # shape == 'polylines'
closed = numpy.all(numpy.equal(points[0], points[-1]))
item = Polygon(points,
closed=closed,
fill=False,
label=legend,
color=color,
linestyle=linestyle,
linewidth=linewidth)
if fill and shape == 'polygon':
item.set_hatch('/')
if linestyle != "solid" and linebgcolor is not None:
item = _DoubleColoredLinePatch(item)
item.linebgcolor = linebgcolor
self.ax.add_patch(item)
else:
raise NotImplementedError("Unsupported item shape %s" % shape)
item.set_zorder(z)
if overlay:
item.set_animated(True)
self._overlays.add(item)
return item