Matplotlib Basemap tutorial 01 : Your first map

# BaseMap example by
# tutorial 01

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(figsize=(11.7,8.3))
#Custom adjust of the subplots
ax = plt.subplot(111)
#Let's create a basemap around Belgium
m = Basemap(resolution='i',projection='merc', llcrnrlat=49.0,urcrnrlat=52.0,llcrnrlon=1.,urcrnrlon=8.0,lat_ts=51.0)

m.drawparallels(np.arange(49.,53.,1.),labels=[1,0,0,0],color='black',dashes=[1,0],labelstyle='+/-',linewidth=0.2) # draw parallels
m.drawmeridians(np.arange(1.,9.,1.),labels=[0,0,0,1],color='black',dashes=[1,0],labelstyle='+/-',linewidth=0.2) # draw meridians

5 thoughts on “Matplotlib Basemap tutorial 01 : Your first map”

  1. Hi

    that script is missing a “import numpy as np”

    Adding this, it works fine

    thanks for your helpful website!

  2. Hi,

    With learning the textbook “Python for Data Analysis” by Wes McKinney, I found your blog. It has a plenty of good tips about basemap programming. Thanks.

    Please let me ask a question. I tried the code above, but my IDE returned just “”. When I removed the dashes options (dashes=[1,0]) in m.drawparallels and m. drawmeridians, the code got worked. I’m not sure what is going on. It might be some conflict due to package environment.


  3. Hi !

    Thanks for using my blog!

    Actually, I am not sure what could be the problem… What Python are you using ? 2.7.x ? Anaconda ?



  4. Hello Thomas,
    thanks for your tutorial. I just wanted to note that I had the same problem that Takeshi noted in his comment above… When I removed the dashes=[1,0] from m.drawparallels and m.drawmeridians, it worked fine. FYI – I’m using Python 2.7 with Anaconda.
    I’m not looking for a response… I just thought you may be interested.

    Thank you again.

Leave a Reply

Your email address will not be published. Required fields are marked *