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


Python PatchCollection.set_antialiased方法代码示例

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


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

示例1: cvshade

# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import set_antialiased [as 别名]
def cvshade(clon,clat,valsin,proj='cyl',lon0=215,res='c',blat=30,fz=(11.6,5.8),add=None,cbticksize=12,cbticks=None,nocb=None,vlo=None,vhi=None,lat0=None,wid=12000000,ht=8000000,**kwargs):
	from mpl_toolkits.basemap import Basemap, shiftgrid, addcyclic
	from mcmath import edges
	from matplotlib.patches import Polygon
	from matplotlib.collections import PatchCollection
	from ferr import use

##	dgrid = use('/scratch/local2/u241180/data/mill/MPI_lon-lat-pressure-points_ocean-grid.nc',silent=1)
##	clon = dgrid.v['grid_center_lon'][:]
##	clat = dgrid.v['grid_center_lat'][:]
##	clon_crnr = dgrid.v['grid_corner_lon'][:]
##	clat_crnr = dgrid.v['grid_corner_lat'][:]

	if clon.shape[0] == 4 and clat.shape[0] == 4:
		clat = np.transpose(clat,(1,2,0))
		clon = np.transpose(clon,(1,2,0))

	clonc = clon.reshape((-1,4))
	clatc = clat.reshape((-1,4))

	clonc1 = np.where(clonc < 35, clonc + 360, clonc)
	clonc2 = np.empty_like(clonc1)
	clatc2 = clatc.copy()
	lhs_x = np.empty((0,4),dtype=np.float32)
	lhs_y = np.empty((0,4),dtype=np.float32)
	lhs_val = np.empty(0,dtype=np.float32)
	val_flat = valsin.copy()
	if isinstance(valsin,np.ma.MaskedArray):
		val_flat[val_flat.mask] = np.nan
	val_flat = val_flat.flatten()

	for ii in xrange(clonc1.shape[0]):
		clonc2[ii] = clonc1[ii]
		if ((clonc1[ii] > 350).any() & (clonc1[ii] < 50).any()):
			clonc2[ii] = np.where(clonc1[ii] < 50, 395., clonc1[ii])
			lhs_x = np.append(lhs_x,np.where(clonc1[ii] > 50,35.,clonc1[ii]).reshape(1,-1),axis=0)
			lhs_y = np.append(lhs_y,clatc2[ii].reshape(1,-1),axis=0)
			lhs_val = np.append(lhs_val,val_flat[ii])

	val2 = np.append(val_flat,lhs_val)
	if isinstance(valsin,np.ma.MaskedArray):
		val2 = np.ma.masked_invalid(val2)
	clonc2 = np.append(clonc2,lhs_x,axis=0)
	clatc2 = np.append(clatc2,lhs_y,axis=0)

	if proj == 'cyl':
		m1 = Basemap(projection='cyl',llcrnrlat=-90,urcrnrlat=90,\
					 llcrnrlon=35,urcrnrlon=395,resolution='c')
	elif proj == 'moll':
		m1 = Basemap(projection='moll',lon_0=lon0)
	elif proj == 'npl':
		m1 = Basemap(projection='nplaea',boundinglat=blat,lon_0=lon0,resolution='l')
	elif proj == 'spl':
		m1 = Basemap(projection='splaea',boundinglat=blat,lon_0=lon0,resolution='l')
	elif proj == 'laea':
		if (lat0 is None):
			raise MCPlotError("central latitude not specified")
		m1 = Basemap(width=wid,height=ht,resolution='l',projection='laea',\
            lat_ts=lat0,lat_0=lat0,lon_0=lon0)
	else:
		raise MCPlotError("no proj %s found!" % proj)

	if add is None:
		fig = plt.figure(figsize=fz)
		ax = fig.add_axes((0.05,0.05,0.8,0.9),autoscale_on=False)
	else:
		fig = plt.gcf()
		ax = plt.gca()

	patches = np.empty(clonc2.shape[0],dtype=object)

	for ii in xrange(clonc2.shape[0]):
		xx1 = clonc2[ii]
		yy1 = clatc2[ii]
		xx,yy = m1(xx1,yy1)
		indx = np.array(zip(xx,yy))
		patches[ii] = Polygon(indx, True)

	p1 = PatchCollection(patches, edgecolors='none', linewidths=0,**kwargs)

	p1.set_array(val2)
	if ((vlo is not None) & (vhi is not None)):
		p1.set_clim(vmin=vlo,vmax=vhi)
	p1.set_antialiased(False)
	m1.drawmapboundary()
##	ax = gca()
	ax.add_collection(p1)
	m1.drawcoastlines()
	
	if not bool(nocb):
		if add is None:
			ax2 = fig.add_axes((0.89,0.1,0.02,0.8),autoscale_on=False)
			if cbticks is None:
				plt.colorbar(p1,cax=ax2,ax=ax,extend='both')
			else:
				plt.colorbar(p1,cax=ax2,ax=ax,extend='both',ticks=cbticks)
		else:
			bbox1 = ax.get_position()
			endx = bbox1.get_points()[1,0]
			endy = bbox1.get_points()[1,1]
#.........这里部分代码省略.........
开发者ID:koldunovn,项目名称:py_klimacampus,代码行数:103,代码来源:mcp.py


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