def redraw_overplot_on_image(self, *args):
if self.star_center_patch is not None:
self.ztv_frame.primary_image_panel.axes.patches.remove(self.star_center_patch)
if self.star_aperture_patch is not None:
self.ztv_frame.primary_image_panel.axes.patches.remove(self.star_aperture_patch)
if self.sky_aperture_patch is not None:
self.ztv_frame.primary_image_panel.axes.patches.remove(self.sky_aperture_patch)
self.star_center_patch = Circle([self.xcentroid, self.ycentroid], 0.125, color=self.aprad_color)
self.ztv_frame.primary_image_panel.axes.add_patch(self.star_center_patch)
self.star_aperture_patch = Circle([self.xcentroid, self.ycentroid], self.aprad, color=self.aprad_color, alpha=self.alpha)
self.ztv_frame.primary_image_panel.axes.add_patch(self.star_aperture_patch)
self.sky_aperture_patch = Wedge([self.xcentroid, self.ycentroid], self.skyradout, 0., 360.,
width=self.skyradout - self.skyradin, color=self.skyrad_color, alpha=self.alpha)
self.ztv_frame.primary_image_panel.axes.add_patch(self.sky_aperture_patch)
self.ztv_frame.primary_image_panel.figure.canvas.draw()
self.hideshow_button.SetLabel(u"Hide")
python类Wedge()的实例源码
GraphicRecord.py 文件源码
项目:DnaFeaturesViewer
作者: Edinburgh-Genome-Foundry
项目源码
文件源码
阅读 26
收藏 0
点赞 0
评论 0
def __init__(self, center, radius, theta1, theta2, width, direction=+1,
**kwargs):
self.direction = direction
self.radius = radius
mpatches.Wedge.__init__(self, center, radius,
theta1, theta2, width,
**kwargs)
self._recompute_path()
def redraw_overplot_on_image(self, *args):
if self.star_center_patch is not None:
self.ztv_frame.primary_image_panel.axes.patches.remove(self.star_center_patch)
if self.star_aperture_patch is not None:
self.ztv_frame.primary_image_panel.axes.patches.remove(self.star_aperture_patch)
if self.sky_aperture_patch is not None:
self.ztv_frame.primary_image_panel.axes.patches.remove(self.sky_aperture_patch)
self.star_center_patch = Circle([self.xcentroid, self.ycentroid], 0.125, color=self.aprad_color)
self.ztv_frame.primary_image_panel.axes.add_patch(self.star_center_patch)
self.star_aperture_patch = Circle([self.xcentroid, self.ycentroid], self.aprad, color=self.aprad_color, alpha=self.alpha)
self.ztv_frame.primary_image_panel.axes.add_patch(self.star_aperture_patch)
self.sky_aperture_patch = Wedge([self.xcentroid, self.ycentroid], self.skyradout, 0., 360.,
width=self.skyradout - self.skyradin, color=self.skyrad_color, alpha=self.alpha)
self.ztv_frame.primary_image_panel.axes.add_patch(self.sky_aperture_patch)
self.ztv_frame.primary_image_panel.figure.canvas.draw()
self.hideshow_button.SetLabel(u"Hide")
def wedge(self, path: Path) -> Wedge:
""" Generates the patches wedge object corresponding to `path`."""
return Wedge((self.origin[0], self.origin[1]),
self._wedge_outer_radius(path),
self._angles[path].theta1,
self._angles[path].theta2,
width=self.wedge_width(path),
label=self.format_text(path),
facecolor=self.face_color(path),
edgecolor=self.edge_color(path),
linewidth=self.line_width(path),
fill=True,
alpha=self.alpha(path))
# todo: supply rest of the arguments
def plot_test(self):
ax = plt.subplot(111)
ax.set_xlim([-5, 5])
ax.set_ylim([-5, 5])
w = Wedge((0, 0), 1, 0, 90, fc='k')
ax.plot(0, 0, ms=0)
ax.add_artist(w)
plt.show()
GraphicRecord.py 文件源码
项目:DnaFeaturesViewer
作者: Edinburgh-Genome-Foundry
项目源码
文件源码
阅读 38
收藏 0
点赞 0
评论 0
def _recompute_path(self):
if not self.direction in [-1, +1]:
return mpatches.Wedge._recompute_path(self)
theta1, theta2 = self.theta1, self.theta2
arrow_angle = min(5, abs(theta2 - theta1) / 2)
normalized_arrow_width = self.width / 2.0 / self.radius
if self.direction == +1:
angle_start_arrow = theta1 + arrow_angle
arc = mpatches.Path.arc(angle_start_arrow, theta2)
outer_arc = arc.vertices[::-1] * (1 + normalized_arrow_width)
inner_arc = arc.vertices * (1 - normalized_arrow_width)
arrow_vertices = [
outer_arc[-1],
np.array([np.cos(np.deg2rad(theta1)),
np.sin(np.deg2rad(theta1))]),
inner_arc[0]
]
else:
angle_start_arrow = theta2 - arrow_angle
arc = mpatches.Path.arc(theta1, angle_start_arrow)
outer_arc = arc.vertices * \
(self.radius + self.width / 2.0) / self.radius
inner_arc = arc.vertices[
::-1] * (self.radius - self.width / 2.0) / self.radius
arrow_vertices = [
outer_arc[-1],
np.array([np.cos(np.deg2rad(theta2)),
np.sin(np.deg2rad(theta2))]),
inner_arc[0]
]
p = np.vstack([outer_arc, arrow_vertices, inner_arc])
path_vertices = np.vstack([p, inner_arc[-1, :], (0, 0)])
path_codes = np.hstack([arc.codes,
4 * [mpatches.Path.LINETO],
arc.codes[1:],
mpatches.Path.LINETO,
mpatches.Path.CLOSEPOLY])
path_codes[len(arc.codes)] = mpatches.Path.LINETO
# Shift and scale the wedge to the final location.
path_vertices *= self.r
path_vertices += np.asarray(self.center)
self._path = mpatches.Path(path_vertices, path_codes)
def __init__(self,
input_pv: MutableMapping[Path, float],
axes, # todo: make optional argument?
origin=(0., 0.),
cmap=plt.get_cmap('autumn'),
base_ring_width=0.4,
base_edge_color=(0, 0, 0, 1),
base_line_width=0.75,
plot_center=False,
plot_minimal_angle=0,
label_minimal_angle=0,
order="value reverse",
base_textbox_props = None):
# *** Input & Config *** (emph)
self.input_pv = input_pv
self.axes = axes
self.cmap = cmap
self.origin = origin
self.base_wedge_width = base_ring_width
self.base_edge_color = base_edge_color
self.base_line_width = base_line_width
self.plot_center = plot_center
self.plot_minimal_angle = plot_minimal_angle
self.label_minimal_angle = label_minimal_angle
self.order = order
self.base_textbox_props = base_textbox_props
if not base_textbox_props:
self.base_textbox_props = dict(boxstyle="round, pad=0.2",
fc=(1, 1, 1, 0.8),
ec=(0.4, 0.4, 0.4, 1),
lw=0.)
# *** Variables used for computation *** (emph)
self._completed_pv = None # type: Dict[Path, float]
self._completed_paths = None # type: List[Path]
self._max_level = None # type: int
self._structured_paths = None # type: List[List[List[Path]]]
self._angles = None # type: Dict[Path, Angles]
# *** "Output" *** (emph)
self.wedges = {} # type: Dict[Path, Wedge]