Skip to content

[MNT]: Streamline mpltoolkits.axes_grid.Grid API #27963

@timhoffm

Description

@timhoffm

Summary

The current interface is neither very intuitive nor practical nor in line with the traditional gridspec logic.

Proposed fix

Half a note to self, because this is not completely thought through:

  • The parameter ngrids seems not to be working (usage raises)
  • The attributes ngrids is not helpful. It's misnomed (naxes would be better), and it's equivalent to len(grid) or len(grid.axes_all).
  • Not sure what we need grid.axes_llc for. That seems quite specific.
  • The 2D grid arrangement axes_row, axes_column are lists of lists. In contrast subplots returns an array. Thus, you need double indexing grid.axes_row[row][col} and cannot use the multi-index axs[row, col].
  • Having the direction parameter and grid.axes_row, grid.axes_column is basically two redundant approaches towards ordering.

Possible improvements:

  • deprecate ngrids attribute - replaced by Fix ngrids support in axes_grid.Grid(). #27972
  • add an attribute grid.axes or maybe even grid.axs (in analogy to fig, axs = plt.subplots(2, 3)), which is a ndarray of the Axes. Hence one could do grid.axs[row, column].
  • maybe (??) soft-deprecate axes_all, axes_row, axes_col, direction?
  • in Grid.__init__ make everything after nrows_ncols kw-only
  • would be nice to have a default rect, but that requires reorganizing parameter order because that's before nrows_ncols.
    Might be possible migrate
    def __init__(self, fig, rect, nrows_ncols, *, ...)
    
    to
    def __init__(self, nrows_ncols, *, rect, ...)
    
    with reasonable deprecation warnings and catching inappropriate use. - But would have to think this through

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