MapsGrid

class eomaps.mapsgrid.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.

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!

Methods

add_annotation([ID, xy, xy_crs, text, update])

This will execute the corresponding action on ALL Maps objects of the MapsGrid!

add_colorbar([pos, inherit_position, ...])

This will execute the corresponding action on ALL Maps objects of the MapsGrid!

add_compass([pos, pos_transform, scale, ...])

This will execute the corresponding action on ALL Maps objects of the MapsGrid!

add_gdf(gdf[, picker_name, pick_method, ...])

This will execute the corresponding action on ALL Maps objects of the MapsGrid!

add_line(xy[, xy_crs, connect, n, del_s, ...])

This will execute the corresponding action on ALL Maps objects of the MapsGrid!

add_logo([filepath, position, size, pad, ...])

Add a small image (png, jpeg etc.) to the map.

add_marker([ID, xy, xy_crs, radius, ...])

This will execute the corresponding action on ALL Maps objects of the MapsGrid!

add_scalebar(m[, preset, scale, n, ...])

This will execute the corresponding action on ALL Maps objects of the MapsGrid!

apply_layout(layout)

Set the positions of all axes of the current figure based on a given layout.

cleanup()

create_axes(ax_init[, name])

Create (and return) an ordinary matplotlib axes.

edit_layout([filepath])

Activate the "layout-editor" to quickly re-arrange the positions of subplots.

get_layout([filepath, override, precision])

Get the positions of all axes within the current plot.

join_limits()

Join axis limits between all Maps objects of the grid (only possible if all maps share the same crs!)

new_layer([layer])

plot_map([layer, dynamic, set_extent, ...])

This will execute the corresponding action on ALL Maps objects of the MapsGrid!

redraw(*args)

savefig(**kwargs)

Save the current figure as an image or vector graphic to a file.

set_classify_specs([scheme])

This will execute the corresponding action on ALL Maps objects of the MapsGrid!

set_data([data, x, y, crs, encoding, cpos, ...])

This will execute the corresponding action on ALL Maps objects of the MapsGrid!

share_click_events()

Share click events between all Maps objects of the grid

share_move_events()

Share move events between all Maps objects of the grid

share_pick_events([name])

Share pick events between all Maps objects of the grid

show([clear])

Show the map (only required for non-interactive matplotlib backends).

snapshot(*args, **kwargs)

subplots_adjust(**kwargs)

Update the subplot parameters of the grid.

Attributes

add_feature

Interface to features provided by NaturalEarth.

add_wms

A collection of open-access WebMap services that can be added to the maps.

children

f

set_shape

Set the plot-shape to represent the data-points.

util

A collection of utility tools that can be added to EOmaps plots.