xoa.plot.plot_minimap

Contents

xoa.plot.plot_minimap#

xoa.plot.plot_minimap(obj, ax=None, parent=None, loc=None, size=None, fig=None, extent=None, min_extent=None, gridlines=None, ocean_color=None, land_color=None, land_scale='110m', plot_coords='auto', coords_markersize=None, coords_linewidth=None, coords_color=None, coords_facecolor=None, **kwargs)[source]#

Plot a small map to show the geographic situation of coordinates

The default values of the parameters that are None come from the plot.minimap_<name> options.

Parameters:
  • obj (xarray.DataArray, xarray.Dataset, tuple) – Object that contains lon and lat coordinates. The object must contain unique and identifiable geographic coordinates that can be retrieved with xoa.coords.get_lon() and xoa.coords.get_lat(). In case of a tuple, it should a couple of (lon, lat) xarray.DataArray.

  • ax (None, list, cartopy.mpl.geoaxes.GeoAxes) – A matplotlib axes instance or a list that defines the bounding box of the axes to be created [xmin, ymin, width, height] or [xmin, ymin, size] in figure coordinates. It defaults to the upper right corner of the figure, or to an inset of parent.

  • parent (None, matplotlib.axes.Axes) – Axes in which the minimap is inset, which avoids to enlarge the figure and to hide its content: it is placed at loc when ax is not given.

  • loc (None, str) – Corner of parent: "upper right", "upper left", "lower right" or "lower left".

  • size (None, float) – Width of the inset relative to the one of parent.

  • fig (figure) – Figure instance

  • extent (None, str, float) – Either "global" for a global minimap, or the margin added to the coordinates bounding box expressed relative to the coordinates extent: a value of 1.0 means a margin equal to the extent.

  • min_extent (None, float, (float, float)) – Minimal extent in degrees. See xoa.geo.get_extent()

  • gridlines (None, bool) – Add gridlines.

  • ocean_color (None, color) – A matplotlib color for oceans. If None, it defaults to cartopy.feature.COLORS["ocean"].

  • land_color (None, color) – A matplotlib color for lands. If None, it defaults to cartopy.feature.COLORS["land"].

  • plot_coords ({'auto', True, None, 'box', 'filledbox', 'points', 'lines', 'center', 'filled', False}) –

    Type of plot for coordinates

    • 'auto'|True|None: infer from coords: lines for 1D series, outline for 2D grids, else points

    • 'box': rectangle of coords extent

    • 'filledbox': filled rectangle of coords extent

    • 'points': scatter plot

    • 'lines': as lines

    • 'center': a single point at the center

    • 'filled': filled polygon

    • False: do not plot

  • coords_markersize (None, float) – Size of markers in "points" mode.

  • coords_linewidth (None, float) – Line width in "lines", “box”` and "filledbox" modes.

  • coords_color (None, color) – Matplotlib color.

  • coords_facecolor (None, color) – Matplotlib face color in "filled" and "filledbox" modes. If a float, it is interpreted as an alpha transparency that is applied to coord_color to get the face color.

  • **kwargs – Parameters matching land_<param> are passed to the function that plots lands. Parameters matching coords_<param> are passed to the function that plots coordinates. Parameters matching gridlines_<param> are passed to cartopy.mpl.geoaxes.GeoAxes.gridlines().

Returns:

cartopy.mpl.geoaxes.GeoAxes – An instance of cartopy geographic axes

Example

In [1]: ds = xr.Dataset(coords={"lon": ("station", [-7, -5, -5]), "lat": ("station", [44, 44, 46])})

In [2]: plt.plot([0, 2], [0, 2])
Out[2]: [<matplotlib.lines.Line2D at 0x738beb080ad0>]

In [3]: plot_minimap(ds, extent="global")
Out[3]: <GeoAxes: >

In [4]: plt.figure()
Out[4]: <Figure size 640x480 with 0 Axes>

In [5]: plt.plot([0, 2], [0, 2])
Out[5]: [<matplotlib.lines.Line2D at 0x738beaf0fe00>]

In [6]: plot_minimap(ds, extent=1.2, color="tab:green", gridlines=False, land_color="k")
Out[6]: <GeoAxes: >
../_images/api.plot.plot_minimap.global.png ../_images/api.plot.plot_minimap.regional.png