Skip to content

axes_grid in main library #17095

Closed
Closed
@jklymak

Description

@jklymak

As pointed out by @anntzer

OTOH it may be nice to slowly move axes_grid towards an API more consistent with the rest of mpl. From a very, very quick look, I guess its axis dict could be compared to normal axes' spines dict? (an AxisArtist is vaguely like a Spine, I guess).

Originally posted by @anntzer in #17069 (comment)

I think it would be better if we had a new axes_grid functionality in the main library, giving us freedom to change the API as we see fit.

The issue that axes_grid fixes is fundamentally:

import matplotlib.pylot as plt 

fig, axs = plt.subplots(2, 3 figsize=(5, 3))
for ax in axs.flat:
   ax.set_aspect(1)

returns the following:

AspectIssue

whereas axes_grid would pack these together vertically.

from mpl_toolkits.axes_grid1 import AxesGrid
fig = plt.figure(figsize=(3, 4), facecolor='0.7')
axs = AxesGrid(fig, 111,  # similar to subplot(111)
                 nrows_ncols=(2, 3),  
                 )
for ax in axs:
   ax.set_aspect(1)

AspectIssueAG

(Asside, yes, AxesGrid also makes some sharing assumptions, etc, that need not be made in general)

Neither constrained_layout nor tight_layout will do this packing for us.

proposals?

There are a few possible top-level APIs for this. The simplest may be:

axs = fig.add_axes_grid(gs)

where gs is a subplotspec, just like add_subplot.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions