Skip to content

Commit 0c06f62

Browse files
committed
Fix several broken examples
1 parent d5d8921 commit 0c06f62

File tree

6 files changed

+14
-12
lines changed

6 files changed

+14
-12
lines changed

examples/geos_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ def get_input(prompt):
2020
# plot land-sea mask.
2121
# land red, oceans blue.
2222
# lakes=True means plot inland lakes with ocean color.
23+
m.drawmapboundary()
2324
m.drawlsmask(land_color='red',ocean_color='blue',lakes=True)
2425
# draw parallels and meridians.
2526
m.drawparallels(np.arange(-90.,120.,30.))
2627
m.drawmeridians(np.arange(0.,420.,60.))
27-
m.drawmapboundary()
2828
plt.title('Geostationary Map Centered on Lon=%s' % (lon_0))
2929

3030
# map with continents drawn and filled.

examples/geos_demo_2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
m = Basemap(projection='geos', lon_0=lon_0, satellite_height=satellite_height,
4040
resolution='l', llcrnrlon=ll_lon, llcrnrlat=ll_lat, urcrnrlon=ur_lon, urcrnrlat=ur_lat)
4141
# add data
42-
m.imshow(data, cmap=plt.cm.gray, interpolation='nearest')
42+
m.imshow(data[::-1], cmap=plt.cm.gray, interpolation='nearest')
4343
plt.clim(0, 255)
4444
# draw coastlines.
4545
m.drawcoastlines(linewidth=0.5, color=overlay_color)

examples/ortho_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ def get_input(prompt):
2222
# land coral, oceans aqua.
2323
# lakes=True means plot inland lakes with ocean color.
2424
# resolution = 5 (default) means use 5 min dataset (can use 2.5)
25+
m.drawmapboundary()
2526
m.drawcoastlines()
2627
m.drawlsmask(land_color='coral',ocean_color='aqua', lakes=True,\
2728
resolution=resolution,grid=grid)
2829
# draw parallels and meridians.
2930
m.drawparallels(np.arange(-90.,120.,30.))
3031
m.drawmeridians(np.arange(0.,420.,60.))
31-
m.drawmapboundary()
3232
plt.title('Orthographic Map Centered on Lon=%s, Lat=%s' % (lon_0,lat_0))
3333

3434
# map with continents drawn and filled (continent filling fails for

examples/plotcities.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
from __future__ import (absolute_import, division, print_function)
22

3-
from matplotlib.mlab import prctile_rank
3+
import numpy as np
44
import matplotlib.pyplot as plt
55
from mpl_toolkits.basemap import Basemap as Basemap
6+
prctile_rank = lambda x, p: np.searchsorted(np.percentile(x, np.atleast_1d(p)), x)
67

78
# cities colored by population rank.
89

910
m = Basemap()
1011
shp_info = m.readshapefile('cities','cities')
11-
x, y = zip(*m.cities)
12-
pop = []
13-
for item in m.cities_info:
12+
x, y, pop = [], [], []
13+
for item, (x_i, y_i) in zip(m.cities_info, m.cities):
1414
population = item['POPULATION']
15-
if population < 0: continue # population missing
16-
pop.append(population)
17-
popranks = prctile_rank(pop,100)
15+
if population >= 0:
16+
pop.append(population)
17+
x.append(x_i)
18+
y.append(y_i)
19+
popranks = prctile_rank(pop,np.linspace(0, 100, 101))
1820
colors = []
1921
for rank in popranks:
2022
colors.append(plt.cm.jet(float(rank)/100.))

examples/plotozone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666

6767
toplot = np.ma.masked_values(o3[0, 0], 0.) * 1000.
6868
bounds = np.percentile(toplot.compressed().ravel(), np.linspace(5, 95, 9).tolist())
69-
ptch = m.pcolor(X, Y, toplot, cmap = WhGrYlBu, norm = plt.matplotlib.colors.BoundaryNorm(bounds, 20), vmin = bounds[0], vmax = bounds[-1])
69+
ptch = m.pcolor(X, Y, toplot, cmap = WhGrYlBu, norm = plt.matplotlib.colors.BoundaryNorm(bounds, 20))
7070

7171
# Add a colorbar using proportional spacing, but
7272
# colors based on 10 distinct bins

examples/warpimage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
# define orthographic projection centered on Europe.
8282
m = Basemap(projection='ortho',lat_0=40,lon_0=40,resolution='l')
8383
# plot a gray-scale image specified from a URL.
84-
im = m.warpimage("http://earthobservatory.nasa.gov/Features/BlueMarble/Images/gebco_bathy.5400x2700.jpg")
84+
im = m.warpimage("https://eoimages.gsfc.nasa.gov/images/imagerecords/73000/73963/gebco_08_rev_bath_3600x1800_color.jpg")
8585
# draw coastlines.
8686
m.drawcoastlines(linewidth=0.5,color='0.5')
8787
# draw lat/lon grid lines every 30 degrees.

0 commit comments

Comments
 (0)