本文整理汇总了Python中matplotlib.patches.Polygon.set_gid方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.set_gid方法的具体用法?Python Polygon.set_gid怎么用?Python Polygon.set_gid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.patches.Polygon
的用法示例。
在下文中一共展示了Polygon.set_gid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ScatterGraph
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import set_gid [as 别名]
def ScatterGraph(self):
AnnotatedArtists = []
#
# Compute the scatter plot for this cluster
#
NumberOfFrames = self.Data.GetNumberOfFrames()
NumberOfObjects = self.Data.GetNumberOfObjects()
FirstObject = self.Data.GetFirstObject() - 2 # Include filtered and noise
LastObject = self.Data.GetLastObject()
TasksPerFrame = self.Data.GetTasksPerFrame()
SelectedFrame = self.GUI.GetSelectedFrame()
SelectedCluster = self.GUI.GetSelectedCluster()
SelectedMetricX = self.GUI.GetSelectedMetricX()
SelectedMetricY = self.GUI.GetSelectedMetricY()
if self.GUI.in_3D():
SelectedMetricZ = self.GUI.GetSelectedMetricZ()
# cursor = Cursor(self.ScatterPlotAxes, useblit=True, color='black', linewidth=1 )
for current_frame in range(1, NumberOfFrames+1):
for current_object in range(FirstObject, LastObject+1):
(r, g, b) = Decorations.RGBColor0_1(current_object)
#
# Compute the scatter plot for this cluster
#
xdata = self.Data.GetClusterData( current_frame, current_object, SelectedMetricX )
ydata = self.Data.GetClusterData( current_frame, current_object, SelectedMetricY )
if (len(xdata) == 0) or (len(ydata) == 0):
continue
if self.GUI.in_3D():
zdata = self.Data.GetClusterData( current_frame, current_object, SelectedMetricZ )
if (len(zdata) == 0):
continue
if (self.GUI.in_Trajectory_View()):
if self.GUI.RatioX():
xdata = xdata * TasksPerFrame[current_frame-1]
if self.GUI.RatioY():
ydata = ydata * TasksPerFrame[current_frame-1]
if self.GUI.in_3D() and self.GUI.RatioZ():
zdata = zdata * TasksPerFrame[current_frame-1]
if self.GUI.in_3D():
scatter = self.ScatterPlotAxes.scatter( xdata, ydata, zdata, color=(r, g, b), zorder=2, s=50, marker=Decorations.ChooseMarker(current_object), picker=True )
else:
scatter = self.ScatterPlotAxes.scatter( xdata, ydata, color=(r, g, b), zorder=2, s=50, marker=Decorations.ChooseMarker(current_object), picker=True )
thumb = self.GUI.GetThumbAxes(current_frame).scatter( xdata, ydata, color=(r, g, b), zorder=2, s=100, marker=Decorations.ChooseMarker(current_object))
thumb.set_visible( False )
self.Thumbs[(current_object, current_frame)] = thumb
scatter.set_gid( self.Data.PrettyCluster(current_object) )
scatter.set_visible( False )
self.Scatters[(current_object, current_frame)] = scatter
AnnotatedArtists.append( scatter )
#
# Compute the centroid for this cluster
#
centroid_x = nanmean( xdata )
centroid_y = nanmean( ydata )
if self.GUI.in_3D():
centroid_z = nanmean( zdata )
centroid = self.ScatterPlotAxes.scatter( centroid_x, centroid_y, centroid_z, s=50, color=(r, g, b), edgecolor="black", marker="o", zorder=3, picker=True )
self.Trajectories[(current_object, current_frame)] = (centroid_x, centroid_y, centroid_z)
else:
centroid = self.ScatterPlotAxes.scatter( centroid_x, centroid_y, s=50, color=(r, g, b), edgecolor="black", marker="o", zorder=3, picker=True)
self.Trajectories[(current_object, current_frame)] = (centroid_x, centroid_y)
centroid.set_gid( self.Data.PrettyCluster(current_object) )
centroid.set_visible(False)
self.Centroids[(current_object, current_frame)] = centroid
AnnotatedArtists.append( centroid )
#
# Compute the convex hull for this cluster
#
if (AvailableHulls) and self.GUI.in_2D():
points = np.array( zip(xdata, ydata) )
if (len(points) < 3):
continue
try:
hull = ConvexHull( points, qhull_options='Pp' )
vertices = hull.vertices
except:
vertices = []
if (len(vertices) > 0):
polygon_points = []
for vertice in vertices:
polygon_points.append( (points[vertice][0], points[vertice][1]) )
hull_polygon = Polygon(polygon_points, closed=True, alpha=0.5, color=Decorations.RGBColor0_1(current_object), zorder=4, lw=10)
hull_polygon.set_gid( self.Data.PrettyCluster(current_object) )
hull_polygon.set_visible(False)
self.Hulls[(current_object, current_frame)] = hull_polygon
#.........这里部分代码省略.........