如何在底图上添加标题下方的间距?

时间:2015-10-14 13:54:14

标签: python title patch matplotlib-basemap

我想在图形和标题之间添加间距。现在,标题与经线重叠,如下图所示,我想避免这样做。谁能告诉我怎么做?提前谢谢!

Basemap Plot

1 个答案:

答案 0 :(得分:2)

你可以使用suptitle()功能并调整你的身材。

from mpl_toolkits.basemap import Basemap, cm
import numpy as np
import matplotlib.pyplot as plt


fig = plt.figure(figsize=(15,8))
# create Basemap instance.
m = Basemap(projection='lcc',lat_0=-30,lon_0=-50,
            llcrnrlat=-30,urcrnrlat=10,
            llcrnrlon=-80,urcrnrlon=-20,
            resolution='c')
# draw coastlines, state and country boundaries, edge of map.
m.drawcoastlines()
m.drawstates()
m.drawcountries()

# draw parallels.
parallels = np.arange(-90.,90,10.)
m.drawparallels(parallels,labels=[1,0,0,0],fontsize=10)
# draw meridians
meridians = np.arange(180.,360.,10.)
m.drawmeridians(meridians,labels=[0,0,1,1],fontsize=10)

# add title
plt.title('PROBLEM!!')


fig = plt.figure(figsize=(15,8))
# create Basemap instance.
m = Basemap(projection='lcc',lat_0=-30,lon_0=-50,
            llcrnrlat=-30,urcrnrlat=10,
            llcrnrlon=-80,urcrnrlon=-20,
            resolution='c')
# draw coastlines, state and country boundaries, edge of map.
m.drawcoastlines()
m.drawstates()
m.drawcountries()

# draw parallels.
parallels = np.arange(-90.,90,10.)
m.drawparallels(parallels,labels=[1,0,0,0],fontsize=10)
# draw meridians
meridians = np.arange(180.,360.,10.)
m.drawmeridians(meridians,labels=[0,0,1,1],fontsize=10)

# add title
plt.suptitle('NO PROBLEM!!')
plt.show()