3

I want to add a spacing between the figure and the title. Right now, the title is overlapping with the meridions as in the figure below and I would like avoid that. Can someone tell me how to do this? Thanks in advance!

Basemap Plot

takachanbo
  • 633
  • 2
  • 6
  • 15
  • Are you using `plot.title()` or `plot.suptitle()`? – K. Shores Oct 18 '15 at 05:02
  • I'm using plot.title(). – takachanbo Oct 19 '15 at 14:50
  • 1
    You essentially have a Matplotlib figure. Does the first answer here work? `plot.title('Variance', y=1.08)` [Python Matplotlib figure title overlaps axes label...](http://stackoverflow.com/questions/12750355/python-matplotlib-figure-title-overlaps-axes-label-when-using-twiny) – Todd Oct 19 '15 at 15:58
  • If you try `plot.suptitle()` you will find that it places the title a bit higher than `plot.title()` does. Try that to see if it fixes it. – K. Shores Oct 19 '15 at 17:02
  • Thank you everyone for your comments. plot.title('Variance', y=1.08) works great! The plot.suptitle() function works fine when there is only one plot but does not work well when I want to have individual titles over each subplot. – takachanbo Oct 21 '15 at 15:32

1 Answers1

2

You could use suptitle() function and resize your figure.

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()
iury simoes-sousa
  • 1,440
  • 3
  • 20
  • 37