当前位置: 首页>>代码示例>>Python>>正文


Python LineCollection.set_picker方法代码示例

本文整理汇总了Python中matplotlib.collections.LineCollection.set_picker方法的典型用法代码示例。如果您正苦于以下问题:Python LineCollection.set_picker方法的具体用法?Python LineCollection.set_picker怎么用?Python LineCollection.set_picker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.collections.LineCollection的用法示例。


在下文中一共展示了LineCollection.set_picker方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plotPattern

# 需要导入模块: from matplotlib.collections import LineCollection [as 别名]
# 或者: from matplotlib.collections.LineCollection import set_picker [as 别名]
	def plotPattern(self, type, stats):
		"""Common graph function for read and writes, type is either 'read' or 'write'. Stats is a bool that indicates whether to print statistics or not."""
		names = self.filenames(type) #unique names of used files				
		if not self.fileName in names:
			print self.fileName, "is not in our data set"			 
			return					
									
		if self.data == None:
			self.__prepareData()
			
		self.axes.clear()
		
		graphdata = np.column_stack((self.data['off'], self.data['start'], self.data['off']+ self.data['size'], self.data['start'] + self.data['dur']))

		lineSegments = LineCollection(graphdata.reshape(-1,2,2), linewidths=(4));
		lineSegments.set_picker(True)		
		self.lineCol = self.axes.add_collection(lineSegments)
	
		maxEnd = max(graphdata[:,2])
		maxTime = max(graphdata[:,3])
													
		if stats:
			  self.__printStats()

		self.axes.xaxis.set_major_formatter(FuncFormatter(self.__xFormater))
		self.axes.grid(color='grey', linewidth=0.5)
		self.axes.set_xlabel("file offset (kiB)", fontsize=16);
		self.axes.set_ylabel("time (ms)", fontsize=16);
		self.axes.set_xlim(0, maxEnd);						
		self.axes.set_ylim(self.startTime, maxTime);
		
		self.fig.suptitle('%s' % self.__elideText(self.fileName), fontsize=9)
#			ticks = self.__getTicks(0, maxEnd)
#			plt.xticks(ticks);
		self.fig.autofmt_xdate()			
开发者ID:carverdamien,项目名称:ioapps,代码行数:37,代码来源:grapher.py

示例2: PlotCtrl

# 需要导入模块: from matplotlib.collections import LineCollection [as 别名]
# 或者: from matplotlib.collections.LineCollection import set_picker [as 别名]

#.........这里部分代码省略.........
        :return:
        """

        if len(data) == 0:
            return

        # unpack the dates, values and replace nodata with None
        dates, values = zip(*data)
        nvals = numpy.array(values, dtype=numpy.float)
        nvals[nvals == noDataValue] = None
        nvals[numpy.isnan(nvals)] = None

        p = self.axes.plot_date(dates, nvals, label=name, linestyle="None", marker=".")
        self.axes.set_ylabel(ylabel)

        # save each of the plots
        self.plots.extend(p)

        self.redraw()

    def plot_polygon(self, data, color):
        poly_list = []
        for item in data:
            reference = item.GetGeometryRef(0)
            points = numpy.array(reference.GetPoints())
            a = tuple(map(tuple, points[:, 0:2]))
            poly_list.append(a)

        self.poly_list = poly_list

        # Plot multiple polygons and add them to collection as individual polygons
        for poly in self.poly_list:
            p_coll = PolyCollection([poly], closed=True, facecolor=color, alpha=0.5, edgecolor=None, linewidths=(2,))
            p_coll.set_picker(True)  # Enable pick event
            self.axes.add_collection(p_coll, autolim=True)

    def plot_point(self, data, color):  # Rename to plot scatter
        # get x,y points
        x, y = zip(*[(g.GetX(), g.GetY()) for g in data])
        self.x_scatter_data, self.y_scatter_data = x, y
        collection = self.axes.scatter(x, y, marker="o", color=color, picker=True)
        return collection

    def plot_linestring(self, data, color):
        """
        A segment is from point A to point b. It is created from grabbing the previous point to the next point
        :param data: geometry object
        :param color:  # Hexadecimal
        :return:
        """
        segments = []
        self.line_segments = {}
        self.segment_line = {}
        index = 0  # Keeps track of how many lines to plot. Should match len(data)
        last_segment = 0
        points = []
        for geo_object in data:
            for point in geo_object.GetPoints():  # Remove the z coordinate
                points.append(point[:-1])
            self.line_segments[index] = range(last_segment, last_segment + len(points) - 1)
            for i in range(len(points) - 1):  # Create the segments
                segments.append([points[i], points[i + 1]])
                self.segment_line[last_segment + i] = index
            last_segment += len(points) - 1
            index += 1
开发者ID:Castronova,项目名称:EMIT,代码行数:69,代码来源:PlotCtrl.py

示例3: plot

# 需要导入模块: from matplotlib.collections import LineCollection [as 别名]
# 或者: from matplotlib.collections.LineCollection import set_picker [as 别名]

#.........这里部分代码省略.........
		primary_ticks = np.unique(np.array(primary_ticks).flatten())
		primary_labels = [str(round(tick, 2)) for tick in primary_ticks]
		
						
		## Set up the plot framework
		fig, ax = plt.subplots()
		ax.set_position([0.11, 0.05, 0.78, 0.93])
		ax.set_xlim((-0.04, 1.04))
		ax.set_xticks([])
		ax.set_xticklabels([])
		ax.yaxis.grid(color='gray')
		ax.set_yticks(primary_ticks)
		ax.set_yticklabels(primary_labels)

				
		## Form-specific details
		if form == 'kappa':
			kappa_max = max(primary_ticks)
			ax.set_ylim((-1.0 * gap * kappa_max, 1.04*kappa_max))
			ax.set_ylabel("mass")
			
		elif form == 'old':
			ax.set_ylabel("lambda")
			ymin = min([v.start_level for v in self.nodes.itervalues()])
			ymax = max([v.end_level for v in self.nodes.itervalues()])
			rng = ymax - ymin
			ax.set_ylim(ymin - gap*rng, ymax + 0.05*rng)	

		elif form == 'lambda':
			ax.set_ylabel("lambda")
			ymin = min([v.start_level for v in self.nodes.itervalues()])
			ymax = max([v.end_level for v in self.nodes.itervalues()])
			rng = ymax - ymin
			ax.set_ylim(ymin - gap*rng, ymax + 0.05*rng)
			
			ax2 = ax.twinx()
			ax2.set_position([0.11, 0.05, 0.78, 0.93])
			ax2.set_ylabel("alpha", rotation=270)

			alpha_ticks = np.sort(list(set(
				[v.start_mass for v in self.nodes.itervalues()] + \
				[v.end_mass for v in self.nodes.itervalues()])))
			alpha_labels = [str(round(m, 2)) for m in alpha_ticks]

			ax2.set_yticks(primary_ticks)
			ax2.set_yticklabels(alpha_labels)		
			ax2.set_ylim(ax.get_ylim())
		
		elif form == 'alpha':
			ax.set_ylabel("alpha")
			ymin = min([v.start_mass for v in self.nodes.itervalues()])
			ymax = max([v.end_mass for v in self.nodes.itervalues()])
			rng = ymax - ymin
			ax.set_ylim(ymin - gap*rng, ymax + 0.05*ymax)
			
			ax2 = ax.twinx()
			ax2.set_position([0.11, 0.05, 0.78, 0.93])
			ax2.set_ylabel("lambda", rotation=270)

			lambda_ticks = np.sort(list(set(
				[v.start_level for v in self.nodes.itervalues()] + \
				[v.end_level for v in self.nodes.itervalues()])))
			lambda_labels = [str(round(lvl, 2)) for lvl in lambda_ticks]

			ax2.set_ylim(ax.get_ylim())
			ax2.set_yticks(primary_ticks)
			ax2.set_yticklabels(lambda_labels)
						
		else:
			raise ValueError('Plot form not understood')				

				
		## Add the line segments
		segclr = np.array([[0.0, 0.0, 0.0]] * len(segmap))
		splitclr = np.array([[0.0, 0.0, 0.0]] * len(splitmap))

		palette = utl.Palette()
		if color_nodes is not None:
			for i, ix in enumerate(color_nodes):
				n_clr = np.alen(palette.colorset)
				c = palette.colorset[i % n_clr, :]
				subtree = self.makeSubtree(ix)

				## set verical colors
				ix_replace = np.in1d(segmap, subtree.nodes.keys())
				segclr[ix_replace] = c

				## set horizontal colors
				if splitmap:
					ix_replace = np.in1d(splitmap, subtree.nodes.keys())
					splitclr[ix_replace] = c
						
		linecol = LineCollection(verts, linewidths=thickness, colors=segclr)
		ax.add_collection(linecol)
		linecol.set_picker(20)
	
		splitcol = LineCollection(lats, colors=splitclr)
		ax.add_collection(splitcol)
				
		return fig, segments, segmap, splits, splitmap
开发者ID:emanuele,项目名称:DeBaCl,代码行数:104,代码来源:geom_tree.py


注:本文中的matplotlib.collections.LineCollection.set_picker方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。