8000 Basemap is now a dependency of document building · matplotlib/matplotlib@f7fdaf8 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f7fdaf8

Browse files
committed
Basemap is now a dependency of document building
1 parent 6095bfa commit f7fdaf8

File tree

2 files changed

+22
-32
lines changed

2 files changed

+22
-32
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ install:
101101
if [[ $BUILD_DOCS == true ]]; then
102102
pip install $PRE numpydoc ipython jsonschema mistune colorspacious
103103
pip install -q $PRE linkchecker
104+
# Installing basemap from github until it's back on pypi
105+
pip install https://github.com/matplotlib/basemap/archive/v1.0.7rel.tar.gz
104106
wget https://github.com/google/fonts/blob/master/ofl/felipa/Felipa-Regular.ttf?raw=true -O Felipa-Regular.ttf
105107
wget http://mirrors.kernel.org/ubuntu/pool/universe/f/fonts-humor-sans/fonts-humor-sans_1.0-1_all.deb
106108
mkdir -p tmp

doc/pyplots/plotmap.py

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
11
import matplotlib.pyplot as plt
22
import numpy as np
33

4-
try:
5-
from mpl_toolkits.basemap import Basemap
6-
have_basemap = True
7-
except ImportError:
8-
have_basemap = False
4+
from mpl_toolkits.basemap import Basemap
95

106

117
def plotmap():
128
# create figure
13-
fig = plt.figure(figsize=(8,8))
9+
fig = plt.figure(figsize=(8, 8))
1410
# set up orthographic map projection with
1511
# perspective of satellite looking down at 50N, 100W.
1612
# use low resolution coastlines.
17-
map = Basemap(projection='ortho',lat_0=50,lon_0=-100,resolution='l')
13+
map = Basemap(projection='ortho', lat_0=50, lon_0=-100, resolution='l')
1814
# lat/lon coordinates of five cities.
19-
lats=[40.02,32.73,38.55,48.25,17.29]
20-
lons=[-105.16,-117.16,-77.00,-114.21,-88.10]
21-
cities=['Boulder, CO','San Diego, CA',
22-
'Washington, DC','Whitefish, MT','Belize City, Belize']
15+
lats = [40.02, 32.73, 38.55, 48.25, 17.29]
16+
lons = [-105.16, -117.16, -77.00, -114.21, -88.10]
17+
cities = ['Boulder, CO', 'San Diego, CA',
18+
'Washington, DC', 'Whitefish, MT', 'Belize City, Belize']
2319
# compute the native map projection coordinates for cities.
24-
xc,yc = map(lons,lats)
20+
xc, yc = map(lons, lats)
2521
# make up some data on a regular lat/lon grid.
26-
nlats = 73; nlons = 145; delta = 2.*np.pi/(nlons-1)
27-
lats = (0.5*np.pi-delta*np.indices((nlats,nlons))[0,:,:])
28-
lons = (delta*np.indices((nlats,nlons))[1,:,:])
22+
nlats = 73
23+
nlons = 145
24+
delta = 2.*np.pi/(nlons-1)
25+
lats = (0.5*np.pi-delta*np.indices((nlats,nlons))[0, :, :])
26+
lons = (delta*np.indices((nlats, nlons))[1, :, :])
2927
wave = 0.75*(np.sin(2.*lats)**8*np.cos(4.*lons))
3028
mean = 0.5*np.cos(2.*lats)*((np.sin(2.*lats))**2 + 2.)
3129
# compute native map projection coordinates of lat/lon grid.
@@ -34,28 +32,18 @@ def plotmap():
3432
# draw map boundary
3533
map.drawmapboundary(color="0.9")
3634
# draw graticule (latitude and longitude grid lines)
37-
map.drawmeridians(np.arange(0,360,30),color="0.9")
38-
map.drawparallels(np.arange(-90,90,30),color="0.9")
35+
map.drawmeridians(np.arange(0, 360, 30), color="0.9")
36+
map.drawparallels(np.arange(-90, 90, 30), color="0.9")
3937
# plot filled circles at the locations of the cities.
40-
map.plot(xc,yc,'wo')
38+
map.plot(xc, yc, 'wo')
4139
# plot the names of five cities.
42-
for name,xpt,ypt in zip(cities,xc,yc):
43-
plt.text(xpt+100000,ypt+100000,name,fontsize=9,color='w')
40+
for name, xpt, ypt in zip(cities, xc, yc):
41+
plt.text(xpt+100000, ypt+100000, name, fontsize=9, color='w')
4442
# contour data over the map.
45-
cs = map.contour(x,y,wave+mean,15,linewidths=1.5)
43+
cs = map.contour(x, y, wave+mean, 15, linewidths=1.5)
4644
# draw blue marble image in background.
4745
# (downsample the image by 50% for speed)
4846
map.bluemarble(scale=0.5)
4947

50-
def plotempty():
51-
# create figure
52-
fig = plt.figure(figsize=(8,8))
53-
fig.text(0.5, 0.5, "Sorry, could not import Basemap",
54-
horizontalalignment='center')
55-
56-
if have_basemap:
57-
plotmap()
58-
else:
59-
plotempty()
48+
plotmap()
6049
plt.show()
61-

0 commit comments

Comments
 (0)
0