To add labels on x and y-axis while using basemap, a solution is to use the pyplot functions xlabel() and/or ylabel():
plt.xlabel('Longitude', labelpad=40)
plt.ylabel('Latitude', labelpad=40)
Note: the option labelpad allows to adjust the distance between the label and the axis.
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
m = Basemap(projection='cyl',llcrnrlat=-90,urcrnrlat=90,
llcrnrlon=-180,urcrnrlon=180,resolution='c')
m.drawcoastlines()
m.fillcontinents()
m.drawparallels(np.arange(-90,90,30),labels=[1,1,0,1], fontsize=8)
m.drawmeridians(np.arange(-180,180,30),labels=[1,1,0,1], rotation=45, fontsize=8)
plt.title('How to add a title on x and y-axis using Basemap ?', fontsize=8)
plt.xlabel('Longitude', labelpad=40, fontsize=8)
plt.ylabel('Latitude', labelpad=40, fontsize=8)
plt.savefig('plot_world_map_using_matplotlib_02.png', bbox_inches='tight')
References
Links | Site |
---|---|
Basemap | Basemap Doc |
How to label parallels/meridian on orthographic projection using matplotlib/basemap in python | stackoverflow |
How to change separation between tick labels and axis labels in Matplotlib | stackoverflow |
set_xlabel() | stackoverflow |