Maps.set_frame#
- Maps.set_frame(rounded=0, gdf=None, set_extent=True, **kwargs)#
Set the properties of the map boundary and the background patch.
You can either use a rectangle with rounded corners or arbitrary geometries provided as a geopandas.GeoDataFrame.
- Parameters:
rounded (float, optional) – If provided, use a rectangle with rounded corners as map boundary line. The corners will be rounded with respect to the provided fraction (0=no rounding, 1=max. radius). The default is None.
gdf (geopandas.GeoDataFrame or path) –
A geopandas.GeoDataFrame that contains geometries that should be used as map-frame.
If a path (string or pathlib.Path) is provided, the corresponding file will be read as a geopandas.GeoDataFrame and the boundaries of the contained geometries will be used as map-boundary.
The default is None.
kwargs –
Additional kwargs to style the boundary line (e.g. the spine) and the background patch
Possible args for the boundary-line:
”edgecolor” or “ec”: The line color
”linewidth” or “lw”: The line width
”linestyle” or “ls”: The line style
”path_effects”: A list of path-effects to apply to the line
Possible args for the background-patch:
”facecolor” or “fc”: The color of the background patch
Examples
>>> m = Maps() >>> m.add_feature.preset.ocean() >>> m.set_frame(fc="r", ec="b", lw=3, rounded=.2)
Customize the map-boundary style
>>> import matplotlib.patheffects as pe >>> m = Maps() >>> m.add_feature.preset.ocean(fc="k") >>> m.set_frame( >>> facecolor=(.8, .8, 0, .5), edgecolor="w", linewidth=2, >>> rounded=.5, >>> path_effects=[pe.withStroke(linewidth=7, foreground="m")])
Set the map-boundary to a custom polygon (in this case the boarder of Austria)
>>> m = Maps() >>> m.add_feature.preset.land(fc="k") >>> # Get a GeoDataFrame with all country-boarders from NaturalEarth >>> gdf = m.add_feature.cultural.admin_0_countries.get_gdf() >>> # set the map-boundary to the Austrian country-boarder >>> m.set_frame(gdf = gdf[gdf.NAME=="Austria"])