def my_round(x, base=5):
return int(base * round(float(x)/base))
lola = [133, 203, 20, 50]
ax = plt.axes(projection=ccrs.PlateCarree(central_longitude=180))
ax.set_extent(lola, crs=ccrs.PlateCarree())
# Draw the gridlines, add labels separately
gl = ax.gridlines(xlocs=np.arange(0,361, 5), ylocs=np.arange(-90,91,5),
linewidth=2, linestyle='--', draw_labels=False)
# Calculate the longitude labels, make anything above 180 to be the negative equivalent
xlabels = np.arange(my_round(np.ceil(lola[0]),5),
my_round(np.floor(lola[1]), 5)+1, 5)
xlabels[labels>180]-=360
ylabels = np.arange(my_round(np.ceil(lola[2]),5),
my_round(np.floor(lola[3]), 5)+1, 5)
# Now plot the labels
glabels = ax.gridlines(xlocs=xlabels,
ylocs=ylabels,
draw_labels=True, alpha=0)
ax.coastlines()