我想知道如何重置我的限制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()
不知何故,如果我map.contourf
用map.pcolormesh
它代替它,就可以解除colorbar
限制。