本文整理汇总了Python中matplotlib.collections.LineCollection.get_linewidths方法的典型用法代码示例。如果您正苦于以下问题:Python LineCollection.get_linewidths方法的具体用法?Python LineCollection.get_linewidths怎么用?Python LineCollection.get_linewidths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.collections.LineCollection
的用法示例。
在下文中一共展示了LineCollection.get_linewidths方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Tracks
# 需要导入模块: from matplotlib.collections import LineCollection [as 别名]
# 或者: from matplotlib.collections.LineCollection import get_linewidths [as 别名]
class Tracks(object):
def __init__(self, ax, tails=None):
self.tracks = None
self.tails = tails
self.initialize_lines(ax)
@staticmethod
def create_trackmap(stormdata):
trackmap = []
for trackid in range(np.max(stormdata['track_id']) + 1):
indexes = np.where(stormdata['track_id'] == trackid)[0]
# Makes sure the track segments are in chronological order
indexes = indexes[np.argsort(stormdata['frame_index'][indexes])]
trackmap.append(indexes)
return trackmap
def remove_lines(self):
if self.tracks is not None:
self.tracks.remove()
self.tracks = None
def initialize_lines(self, ax):
self.remove_lines()
self.tracks = LineCollection([])
ax.add_collection(self.tracks)
def update_lines(self, frame_index, stormdata):
segments = []
for indexes in self.create_trackmap(stormdata):
trackdata = stormdata[indexes]
trackdata = trackdata[trackdata['frame_index'] <= frame_index]
if self.tails:
mask = trackdata['frame_index'] >= (frame_index - self.tails)
trackdata = trackdata[mask]
# There must always be something in a track, even it it is NaNs.
segments.append(zip(trackdata['xcent'], trackdata['ycent'])
or [(np.nan, np.nan)])
self.tracks.set_segments(segments)
def lolite_line(self, indx):
self.hilite_line(indx, 1)
def hilite_line(self, indx, lw=4):
if indx is not None:
lws = self.tracks.get_linewidths()
lws[indx] = lw
self.tracks.set_linewidths(lws)