Description
Problem
Trying to combine subplot_mosaic with axes using various different projections (e.g. one rectilinear axes and one polar axes and one 3d axes) has been requested a few times (once in the original subplot_mosaic thread IIRC, and in #20392 too), and it's something I would recently have been happy to have, too.
Pushing projections directly into subplot_mosaic seems ripe for API bloat, but perhaps another solution would be to add figure.gridspec_mosaic(...)
which takes the same arguments as subplot_mosaic, but returns a dict of subplotspecs, such that one can do something like
specs = fig.gridspec_mosaic(...)
d = {
"foo": fig.add_subplot(specs["foo"], projection=...),
"bar": fig.add_subplot(specs["bar"], projection=...),
...
}
As a side point, I do find the repetition of fig
in each call to add_subplot a bit jarring (as the underlying gridspec is bound to the figure, so that information is actually redundant). Back in #13280 I had proposed to add SubplotSpec.add_subplot() (adding to the figure to which the gridspec is bound), which would allow one to write, here,
specs = fig.gridspec_mosaic(...)
d = {
"foo": specs["foo"].add_subplot(projection=...),
"bar": specs["bar"].add_subplot(projection=...),
...
}
but that idea got shot down back then and even if we decide not to revisit it, even the first form would be nice to have.
Thoughts?
Proposed solution
No response