本文整理汇总了Python中matplotlib.patches.Ellipse.set_hatch方法的典型用法代码示例。如果您正苦于以下问题:Python Ellipse.set_hatch方法的具体用法?Python Ellipse.set_hatch怎么用?Python Ellipse.set_hatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.patches.Ellipse
的用法示例。
在下文中一共展示了Ellipse.set_hatch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw
# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_hatch [as 别名]
def draw(self, axes, figure, color):
mycirc = Ellipse(self.center, self.width, self.height, facecolor='none', edgecolor=color)
mycirc.set_linewidth(1)
mycirc.set_alpha(1)
mycirc.set_facecolor('none')
mycirc.set_hatch('//')
circ = axes.add_artist(mycirc)
figure.canvas.draw()
return circ
示例2: ROIellipse
# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_hatch [as 别名]
class ROIellipse(ROIcircle):
def __getstate__(self):
return {'im':self.im, 'circle':(self.center, self.width, self.height), 'color': self.color}
def __setstate__(self, d):
self.im = d['im']
self.center, self.width, self.height = d['circle']
self.circ = Ellipse(*d['circle'], facecolor='none', edgecolor=self.color)
self.color = self.color
self.patch = None
def draw(self, axes, figure, color):
mycirc = Ellipse(self.center, self.width, self.height, facecolor='none', edgecolor=color)
mycirc.set_linewidth(1)
mycirc.set_alpha(1)
mycirc.set_facecolor('none')
mycirc.set_hatch('//')
circ = axes.add_artist(mycirc)
figure.canvas.draw()
return circ
def motion_notify_callback(self, event):
"""Draw a line from the last selected point to current pointer
position. If left button is held, add points to the coords list
at each movement.
"""
if event.inaxes:
x, y = event.xdata, event.ydata
if event.button == None and self.circ is not None: # Move line around
x0, y0 = self.circ.center
self.circ.height = abs(y-y0)*2
self.circ.width = abs(x-x0)*2
self.fig.canvas.draw()
def button_press_callback(self, event):
"""Left button: add point; middle button: delete point;
right button: fill polygon and stop interaction.
"""
if event.inaxes:
x, y = event.xdata, event.ydata
ax = event.inaxes
if event.button == 1: # If you press the left button
if self.circ == None:
self.circ = Ellipse((x, y), 0.5, 0.5, facecolor='none', edgecolor=self.color)
self.center = x, y
ax.add_artist(self.circ)
else:
self.circ.set_color(self.color)
self.circ.set_edgecolor(self.color)
self.circ.set_facecolor('none')
self.circ.set_linewidth(1)
self.circ.set_alpha(1)
self.circ.set_hatch('//')
self.disconnect()
self.height = self.circ.height
self.width = self.circ.width
self.completion_callback()
elif event.button == 3 and self.circ is not None: # middle button: remove last segment
self.circ.remove()
self.circ = None
self.fig.canvas.draw()
def get_coords(self):
"""Returns the x,y coordinates of that have been selected
so far."""
if not self.center:
raise ValueError("cannot get ellipse coordinates before the dimensions are defined")
return self.center, self.width, self.height
def get_indices(self):
"""Returns a set of points that lie inside the picked polygon."""
if not self.center:
raise ValueError("Cannot get ellipse indices before the dimensions are defined")
x, y = self.center
w = self.width
h = self.height
return ellipse(y, x, h/2., w/2., self.im)