MapsGrid

class eomaps.MapsGrid(r=2, c=2, crs=None, m_inits=None, ax_inits=None, figsize=None, layer='base', f=None, **kwargs)

Initialize a grid of Maps objects

Parameters
  • r (int, optional) – The number of rows. The default is 2.

  • c (int, optional) – The number of columns. The default is 2.

  • crs (int or a cartopy-projection, optional) – The projection that will be assigned to all Maps objects. (you can still change the projection of individual Maps objects later!) See the doc of “Maps” for details. The default is 4326.

  • m_inits (dict, optional) –

    A dictionary that is used to customize the initialization the Maps-objects.

    The keys of the dictionaries are used as names for the Maps-objects, (accessible via mgrid.m_<name> or mgrid[m_<name>]) and the values are used to identify the position of the axes in the grid.

    Possible values are: - a tuple of (row, col) - an integer representing (row + col)

    Note: If either m_inits or ax_inits is provided, ONLY objects with the specified properties are initialized!

    The default is None in which case a unique Maps-object will be created for each grid-cell (accessible via mgrid.m_<row>_<col>)

  • ax_inits (dict, optional) –

    Completely similar to m_inits but instead of Maps objects, ordinary matplotlib axes will be initialized. They are accessible via mg.ax_<name>.

    Note: If you iterate over the MapsGrid object, ONLY the initialized Maps objects will be returned!

  • figsize ((float, float)) – The width and height of the figure.

  • layer (int or str) – The default layer to assign to all Maps-objects of the grid. The default is 0.

  • f (matplotlib.Figure or None) – The matplotlib figure to use. If None, a new figure will be created. The default is None.

  • kwargs – Additional keyword-arguments passed to the matplotlib.gridspec.GridSpec() function that is used to initialize the grid.

f

The matplotlib figure object

Type

matplotlib.figure

gridspec

The matplotlib GridSpec instance used to initialize the axes.

Type

matplotlib.GridSpec

m_<identifier>

The individual Maps-objects can be accessed via mgrid.m_<identifier> The identifiers are hereby <row>_<col> or the keys of the m_inits dictionary (if provided)

Type

eomaps.Maps objects

ax_<identifier>

The individual (ordinary) matplotlib axes can be accessed via mgrid.ax_<identifier>. The identifiers are hereby the keys of the ax_inits dictionary (if provided). Note: if ax_inits is not specified, NO ordinary axes will be created!

Type

matplotlib.axes

join_limits :

join the axis-limits of maps that share the same projection

share_click_events :

share click-callback events between the Maps-objects

share_pick_events :

share pick-callback events between the Maps-objects

create_axes :

create a new (ordinary) matplotlib axes

add_<...> :

call the underlying add_<…> method on all Maps-objects of the grid

set_<...> :

set the corresponding property on all Maps-objects of the grid

subplots_adjust :

Dynamically adjust the layout of the subplots, e.g:

>>> mg.subplots_adjust(left=0.1, right=0.9,
>>>                    top=0.8, bottom=0.1,
>>>                    wspace=0.05, hspace=0.25)

Examples

To initialize a 2 by 2 grid with a large map on top, a small map on the bottom-left and an ordinary matplotlib plot on the bottom-right, use:

>>> m_inits = dict(top = (0, slice(0, 2)),
>>>                bottom_left=(1, 0))
>>> ax_inits = dict(bottom_right=(1, 1))
>>> mg = MapsGrid(2, 2, m_inits=m_inits, ax_inits=ax_inits)
>>> mg.m_top.plot_map()
>>> mg.m_bottom_left.plot_map()
>>> mg.ax_bottom_right.plot([1,2,3])
Returns

Accessor to the Maps objects “m_{row}_{column}”.

Return type

eomaps.MapsGrid

Notes

  • To perform actions on all Maps-objects of the grid, simply iterate over the MapsGrid object!