When drawing “small multiples” — a grid of subplots where each uses the same x and y variables — it can be cleaner to use a pair of labels that collectively annotate the x and y axes of all plots, ideally centered on the horizontal and vertical span of the collection of axes.
Here’s what I mean:
I don’t believe matplotlib has a robust and generic way to create these labels. In the above example, I set the axes-level labels for the middle row/column, which only works when ncol and nrow are odd. It could be possible to get the SubplotSpec bbox and work out where to draw fig.text
labels, but I don’t think these will update properly with tight_layout
/constrained_layout
.
Would it be possible for the matplotlib.gridspec.SubplotSpec
object to define {get,set}_{x,y}label
? How hard would this be to implement? Is there interest?
PS I guess people might reasonably expect subplot-managed titles too. And legends? I can see how this request might get out of hand. Then again, all of these features would be useful if there are abstractions that can make them not too burdensome.