本文整理汇总了Python中matplotlib.collections.PolyCollection.get_paths方法的典型用法代码示例。如果您正苦于以下问题:Python PolyCollection.get_paths方法的具体用法?Python PolyCollection.get_paths怎么用?Python PolyCollection.get_paths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.collections.PolyCollection
的用法示例。
在下文中一共展示了PolyCollection.get_paths方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_poly_collection_2d_to_3d_empty
# 需要导入模块: from matplotlib.collections import PolyCollection [as 别名]
# 或者: from matplotlib.collections.PolyCollection import get_paths [as 别名]
def test_poly_collection_2d_to_3d_empty():
poly = PolyCollection([])
art3d.poly_collection_2d_to_3d(poly)
assert isinstance(poly, art3d.Poly3DCollection)
assert poly.get_paths() == []
示例2: plotCurrent
# 需要导入模块: from matplotlib.collections import PolyCollection [as 别名]
# 或者: from matplotlib.collections.PolyCollection import get_paths [as 别名]
def plotCurrent(self, dtfrom, fnamebase):
#self.figure.clf()
#self.canvas.draw()
#self.loadModel()
self.progressBar.setValue(51)
frmDate = self.dtFrom.dateTime()
#print 'Plotting till date: ' + dtfrom.date().toString()
# get velocity nearest to current time
##dtnow = dt.datetime.utcnow() + dt.timedelta(hours=0)
day = dtfrom.date().day()
month = dtfrom.date().month()
year = dtfrom.date().year()
hour = dtfrom.time().hour()
minute = dtfrom.time().minute()
second = dtfrom.time().second()
msecond = dtfrom.time().msec()
#print dir(dtnow)
#print dtnow.time()
startdt = dt.datetime(year, month, day, hour, minute, second, msecond)
#print startdt
#print start
istart = netCDF4.date2index(startdt,self.time_var,select=self.interp_method)
layer = 0 # surface layer
u = self.nc.variables[self.uvar][istart, layer, :]
v = self.nc.variables[self.vvar][istart, layer, :]
mag = numpy.sqrt((u*u)+(v*v))
#print start
#print istart
self.progressBar.setValue(63)
# Now try plotting speed and vectors with Basemap using a PolyCollection
m = Basemap(projection='merc', llcrnrlat=self.lat.min(), urcrnrlat=self.lat.max(),
llcrnrlon=self.lon.min(), urcrnrlon=self.lon.max(),
lat_ts=self.lat.mean(), resolution=None)
# project from lon,lat to mercator
xnode, ynode = m(self.lon, self.lat)
xc, yc = m(self.lonc, self.latc)
nv = self.nc.variables[self.nvvar][:].T - 1
# create a TRI object with projected coordinates
tri = Tri.Triangulation(xnode, ynode, triangles=nv)
self.progressBar.setValue(77)
sig_lay = self.nc.variables['siglay']
zeta = self.nc.variables['zeta']
# make a PolyCollection using triangles
verts = concatenate((tri.x[tri.triangles][..., None],
tri.y[tri.triangles][..., None]), axis=2)
colorlut = []
fid = 0
for poly in verts:
fid = fid + 1
collection = PolyCollection(verts)
collection.set_edgecolor('none')
self.progressBar.setValue(81)
timestamp=startdt.strftime('%Y-%m-%d %H:%M:%S')
# set the magnitude of the polycollection to the speed
collection.set_array(mag)
#sys.exit(1)
collection.norm.vmin=0
collection.norm.vmax=0.5
#for path in collection.get_paths():
cmap =collection.cmap
featurecount = fid
redArray = matplotlib.colors.makeMappingArray(featurecount,cmap._segmentdata['red'], 1.0)
greenArray = matplotlib.colors.makeMappingArray(featurecount,cmap._segmentdata['green'], 1.0)
blueArray = matplotlib.colors.makeMappingArray(featurecount,cmap._segmentdata['blue'], 1.0)
fid = 0
for path in collection.get_paths():
tricolor = self.makehexcolor(redArray[fid], greenArray[fid], blueArray[fid])
##print tricolor
#.........这里部分代码省略.........