Necessary Imports


In [71]:
import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
from datetime import datetime

Increasing the map size before any drawing methods


In [72]:
def plot_day_night(plt):

    plt.figure(figsize=(15, 5))

Map projection options


In [73]:
map = Basemap(projection='robin',
                  lat_0=-0, lon_0=0,
                  resolution='c')
    # map = Basemap(projection='mill', 
                  # llcrnrlon=-180,llcrnrlat=-90,
                  # urcrnrlon=-180, urcrnrlat=90,)

Plot coastlines, draw countries, label meridians and parallels.


In [74]:
map.drawcoastlines(linewidth=0.25)
    map.drawcountries(linewidth=0.25)
    map.drawparallels(np.arange(-90, 91, 60), labels=[1, 0, 0, 0])
    map.drawmeridians(np.arange(map.lonmin, map.lonmax +30, 60),
                      labels=[0, 0, 0, 1])

    # fill continents 'coral' (with zorder=0), color wet areas 'aqua'
    map.drawmapboundary(fill_color='#00FFFF')
    map.fillcontinents(color='#FFFF00', lake_color='#00FFFF')

    # Show darkness on the regions of the map corresponding to
    # the time and date specifed as current time in UTC
    time = datetime.utcnow()

    map.nightshade(time, color='k', delta=0.25,
                   alpha=0.25, ax=None, zorder=2)


Out[74]:
<matplotlib.contour.QuadContourSet at 0x11da00190>

Map title & plot test


In [75]:
plt.title('Day & Night Map on %s (UTC)' %
              time.strftime("%d %b %Y %H:%M:%S"))

    plt.show()


if __name__ == "__main__":

                plot_day_night(plt)