diff --git a/eomaps/eomaps.py b/eomaps/eomaps.py index 32e726cff..4b79c32b5 100644 --- a/eomaps/eomaps.py +++ b/eomaps/eomaps.py @@ -5450,7 +5450,7 @@ def refetch_wms_on_size_change(self, *args, **kwargs): """Set the behavior for WebMap services on axis or figure size changes.""" refetch_wms_on_size_change(*args, **kwargs) - def _set_gdf_path_boundary(self, gdf): + def _set_gdf_path_boundary(self, gdf, set_extent=True): geom = gdf.to_crs(self.crs_plot).unary_union.boundary if geom.geom_type == "MultiLineString": @@ -5471,17 +5471,17 @@ def _set_gdf_path_boundary(self, gdf): path = mpath.Path(vertices, codes) self.ax.set_boundary(path, self.ax.transData) + if set_extent: + x0, y0 = np.min(vertices, axis=0) + x1, y1 = np.max(vertices, axis=0) - x0, y0 = np.min(vertices, axis=0) - x1, y1 = np.max(vertices, axis=0) - - self.set_extent([x0, x1, y0, y1], gdf.crs) + self.set_extent([x0, x1, y0, y1], gdf.crs) if multi: # TODO apply fix for multi-path geometries (see cartopy PR #2362) _fix_multipath_GeoSpine() - def set_frame(self, rounded=0, gdf=None, **kwargs): + def set_frame(self, rounded=0, gdf=None, set_extent=True, **kwargs): """ Set the properties of the map boundary and the background patch. @@ -5553,7 +5553,7 @@ def set_frame(self, rounded=0, gdf=None, **kwargs): self.ax.spines["geo"].update(kwargs) if gdf is not None: - self._set_gdf_path_boundary(self._handle_gdf(gdf)) + self._set_gdf_path_boundary(self._handle_gdf(gdf), set_extent=set_extent) elif rounded: assert (