Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1df7f68

Browse files
committed
Merge pull request matplotlib#6243 from jenshnielsen/basemapdocs
Require basemap to build docs
2 parents 9e1668b + 4d533b7 commit 1df7f68

File tree

4 files changed

+34
-48
lines changed

4 files changed

+34
-48
lines changed

.travis.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ addons:
2323
- texlive-latex-recommended
2424
- texlive-xetex
2525
- graphviz
26+
- libgeos-dev
2627
# - fonts-humor-sans
2728
# sources:
2829
# - debian-sid
@@ -115,6 +116,13 @@ install:
115116
fi;
116117
117118
- python setup.py install
119+
- |
120+
# Installing basemap from github until it's back on pypi
121+
# We have to install it after matplotlib to avoid pulling in MPL as
122+
# a dependency
123+
if [[ $BUILD_DOCS == true ]]; then
124+
pip install https://github.com/matplotlib/basemap/tarball/master
125+
fi;
118126
119127
script:
120128
# The number of processes is hardcoded, because using too many causes the
@@ -127,7 +135,7 @@ script:
127135
gdb -return-child-result -batch -ex r -ex bt --args python tests.py -s --processes=$NPROC --process-timeout=300 $TEST_ARGS
128136
else
129137
cd doc
130-
python make.py html --small --warningsaserrors
138+
python make.py html --small
131139
# We don't build the LaTeX docs here, so linkchecker will complain
132140
touch build/html/Matplotlib.pdf
133141
linkchecker build/html/index.html

doc/make.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def all():
138138

139139

140140
small_docs = False
141-
warnings_as_errors = False
141+
warnings_as_errors = True
142142

143143
# Change directory to the one containing this file
144144
current_dir = os.getcwd()
@@ -184,14 +184,14 @@ def all():
184184
parser.add_argument("--small",
185185
help="Smaller docs with only low res png figures",
186186
action="store_true")
187-
parser.add_argument("--warningsaserrors",
188-
help="Turn Sphinx warnings into errors",
187+
parser.add_argument("--allowsphinxwarnings",
188+
help="Don't turn Sphinx warnings into errors",
189189
action="store_true")
190190
args = parser.parse_args()
191191
if args.small:
192192
small_docs = True
193-
if args.warningsaserrors:
194-
warnings_as_errors = True
193+
if args.allowsphinxwarnings:
194+
warnings_as_errors = False
195195

196196
if args.cmd:
197197
for command in args.cmd:

doc/pyplots/README

Lines changed: 0 additions & 10 deletions
This file was deleted.

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)