本文整理汇总了Python中matplotlib.cm.nipy_spectral方法的典型用法代码示例。如果您正苦于以下问题:Python cm.nipy_spectral方法的具体用法?Python cm.nipy_spectral怎么用?Python cm.nipy_spectral使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.cm
的用法示例。
在下文中一共展示了cm.nipy_spectral方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _plot_city
# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import nipy_spectral [as 别名]
def _plot_city(self, ds):
"""Plot the results of gyms in a city.
Parameters
----------
self.ds_sorted : xr.Dataset
xr.Dataset with Coordinates: gyms.
Returns
-------
matplotlib.pyplot.figure : matplotlib.pyplot.figure
Creates city plot.
"""
# Create extend of map [W, E, S, N]
extent = [ds['longitude'].values.min(), ds['longitude'].values.max(),
ds['latitude'].values.min(), ds['latitude'].values.max()]
# Setup colors
colors = cm.nipy_spectral(np.linspace(0,1,len(ds['gyms'])))
# Get google map. Scale is for more details. Mapytype can have
# 'terrain' or 'satellite'
g = GoogleVisibleMap(x=[extent[0], extent[1]], y=[extent[2],
extent[3]], scale=4, maptype='terrain')
ggl_img = g.get_vardata()
# Plot map
fig, ax = plt.subplots(1, 1, figsize=(20,20))
sm = Map(g.grid, factor=1, countries=False)
sm.set_rgb(ggl_img)
sm.visualize(ax=ax)
# Plot gym points
for i in range(0, len(ds['gyms'])):
# Create label
self.regcount = i
self._rank() # Add self.rank
_label = self.rank+' '+ds['gyms'].values[i]+': '+\
ds['athlete_names'].values[i]+' ('+str(ds[self.how].values[i])+')'
x, y = sm.grid.transform(ds['longitude'].values[i],
ds['latitude'].values[i])
ax.scatter(x, y, color=colors[i], s=400, label=_label)
plt.title(self.fname+' | '+self.city+' | '+self.column+' | '+self.how)
# Shrink current axis by 20% to make room for legend
box = ax.get_position()
ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
plt.savefig(self.plotdir+self.fname+'_'+self.city+'_'+self.column+'_'+\
self.how+'.png', bbox_inches = 'tight')
#plt.savefig(self.plotdir+self.fname+'_'+self.city+'_'+self.column+\
# self.how+'.png', bbox_inches = 'tight', format='eps')
plt.show()