低调整我的`colorbar`的限制

时间:2015-10-22 05:15:20

标签: python matplotlib-basemap colorbar contourf

我想知道如何重置colorbar的限制,使其轴从0到16而不是0到14。

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
from scipy.io import netcdf
import numpy as np
import os
fig = plt.figure(figsize=(16,6))
map=Basemap(projection='merc',llcrnrlat=-21.25,urcrnrlat=21.25,\
            llcrnrlon=1.25,urcrnrlon=358.75,resolution='c')
map.drawcoastlines()
os.chdir( '/Users/wenyuz/Documents/')
f = netcdf.netcdf_file('precip.mon.mean.nc', 'r')
lon = f.variables['lon']
lat = f.variables['lat']
precip = f.variables['precip']
precip_tm=np.mean(precip[1:,27:45,:],0)
print np.shape(precip_tm)
delta = 2.5
long_west=1.25
long_east=358.75
lat_south=21.25
lat_north=-21.25
x = np.arange(long_west, long_east+delta, delta)
y = np.arange(lat_south, lat_north-delta, -delta)
X1, Y1=np.meshgrid(x,y)
X, Y = map(X1, Y1)
CS = map.contourf(X, Y, precip_tm,cmap=plt.cm.gist_ncar,vmin=0,vmax=16);
cbar = map.colorbar(CS,location="bottom")
cbar.set_clim(0, 16)
cbar.set_label('mm')
plt.title('GPCP: 1979-2008')
f.close()

enter image description here

不知何故,如果我将map.contourf替换为map.pcolormesh,则可以暂停colorbar限制。

0 个答案:

没有答案
相关问题