I also tried with a different dataset, the one from
http://matplotlib.org/basemap/users/examples.html
and I get the same problem
from mpl_toolkits.basemap import Basemap
from netCDF4 import Dataset
import numpy as np
import matplotlib.pyplot as plt
date = '20071215' # date to plot.
# open dataset for that date.
dataset = \
Dataset('
http://www.ncdc.noaa.gov/thredds/dodsC/oisst/NetCDF/AVHRR-AMSR/%s/AVHRR-AMSR/amsr-avhrr-v2.%s.nc.gz'%
(date[0:4],date))
# read sst. Will automatically create a masked array using
# missing_value variable attribute. 'squeeze out' singleton
dimensions.
sst = dataset.variables['sst'][:].squeeze()
# read ice.
ice = dataset.variables['ice'][:].squeeze()
# read lats and lons (representing centers of grid boxes).
lats = dataset.variables['lat'][:]
lons = dataset.variables['lon'][:]
# shift lats, lons so values represent edges of grid boxes
# (as pcolor expects).
delon = lons[1]-lons[0]; delat = lats[1]-lats[0]
lons = (lons - 0.5*delon).tolist()
lons.append(lons[-1]+delon)
lons = np.array(lons,np.float64)
lats = (lats - 0.5*delat).tolist()
lats.append(lats[-1]+delat)
lats = np.array(lats,np.float64)
# create figure, axes instances.
fig = plt.figure()
ax = fig.add_axes([0.05,0.05,0.9,0.9])
m =
Basemap(projection='spaeqd',lat_0=-90,lon_0=180,resolution='l',boundinglat=-40,round=True)
x, y = m(*np.meshgrid(lons, lats))
o=m.drawcoastlines(linewidth=0.25)
o=m.drawcountries(linewidth=0.25)
o=m.fillcontinents(color="grey",lake_color='white')
o=m.drawmeridians(np.arange(0,360,30),labels=[1,1,1,1])
o=m.drawparallels(np.arange(-90,90,10),labels=[1,1,1,1])
cim=m.contour(x[:-1,:-1],y[:-1,:-1],sst,arange(2,28,2),linewidths=0.5,colors='k')
plt.clabel(cim, inline=1, fontsize=10, fmt = '%.1f',)
Marcello: I cannot
reproduce your
problem. From the github pull request you mention, it seems like this
was fixed about 3 months ago. What version of basemap are you running?
-Jeff
------------------------------------------------------------------------------
Everyone
hates slow websites. So do we.
Make your web apps faster with
AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb When I plot contours in a
stereographic south pole plot with a bounding
latitude and the rounded clipping
Basemap(projection='spaeqd',lat_0=-90,lon_0=180,resolution='l',boundinglat=-40,round=True)
I see that the contours are correctly cut-off but not the contour
labels. They appear to be plotted according to a rectangular frame and
not the rounded one (see attached figure).
Is it possible to mask the labels without having to mask the data?
This issue may be related to an older topic:
http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg02892.html
and to a more recent bugfix
https://github.com/matplotlib/basemap/pull/89
but I do not see any other clue
thanks in advance
marcello
------------------------------------------------------------------------------
Everyone
hates slow websites. So do we.
Make your web apps faster with
AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb