polaris.viz.make_room_for_gridline_labels
- polaris.viz.make_room_for_gridline_labels(ax)[source]
Let the layout engine reserve room for a map’s gridline labels
Cartopy draws gridline labels outside the axes, so a layout engine only leaves room for them if the axes report a finite tight bounding box. A
GeoAxesdoes not. Whenever its gridliner draws top or “geo” labels — and geo labels are on by default — cartopy repositions the axes titles to sit above them, and lands them at an infinite position. Matplotlib folds the titles into the tight bounding box, so the box comes back asnan, the layout engine reserves nothing, and the labels are drawn off the canvas: the outermost longitude label is cut in half and every latitude label is lost entirely.Giving the title an explicit position turns cartopy’s repositioning off, which is all it takes for the bounding box to be finite and the margins to be reserved. Polaris titles its spherical plots with
fig.suptitle(), so the axes titles are empty and nothing is drawn differently.- Parameters:
ax (cartopy.mpl.geoaxes.GeoAxes) – The map axes whose gridline labels need room