Slide 5
Slide 5 text
© 2017 IBM Corp.
IBM Cloud &
Watson
@rajrsingh
from mpl_toolkits.basemap import Basemap
from matplotlib.offsetbox import AnnotationBbox
from matplotlib._png import read_png
from itertools import izip
matplotlib.style.use('bmh')
fig, axes = plt.subplots(nrows=1, ncols=2,
figsize=(10, 12))
# background maps
m1 = Basemap(projection='mill',resolution=None,
llcrnrlon=-7.5, llcrnrlat=49.84,urcrnrlon=2.5,
urcrnrlat=59,ax=axes[0])
m1.drawlsmask(land_color='dimgrey',
ocean_color='dodgerBlue',lakes=True)
# temperature map
for [temp,city] in izip(temps,cities):
lat = city[1]
lon = city[2]
if temp>8:
col='indigo'
elif temp>10:
col='darkmagenta'
elif temp>8:
col='red'
elif temp>6:
col='tomato'
elif temp>4:
col='turquoise'
x1, y1 = m2(lon,lat)
bbox_props = dict(boxstyle="round,pad=0.3", fc=col, ec=col, lw=2)
axes[1].text(x1, y1, temp, ha="center", va="center",
size=11,bbox=bbox_props)
plt.tight_layout()
Is this really mapping in 2017?