diff --git a/mlair/plotting/postprocessing_plotting.py b/mlair/plotting/postprocessing_plotting.py index cf96948035d4e6da497c2f9502cdb467ee3ba9c0..ff5c2bc3ee2ef0923ac50f91ce5acd6807e1eb2e 100644 --- a/mlair/plotting/postprocessing_plotting.py +++ b/mlair/plotting/postprocessing_plotting.py @@ -258,14 +258,28 @@ class PlotStationMap(AbstractPlotClass): from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER fig = plt.figure(figsize=(10, 5)) self._ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree()) - self._ax.set_extent([4, 17, 44, 58], crs=ccrs.PlateCarree()) self._gl = self._ax.gridlines(xlocs=range(0, 21, 5), ylocs=range(44, 59, 2), draw_labels=True) self._gl.xformatter = LONGITUDE_FORMATTER self._gl.yformatter = LATITUDE_FORMATTER self._draw_background() self._plot_stations(generators) + self._adjust_extent() plt.tight_layout() + def _adjust_extent(self): + import cartopy.crs as ccrs + + def diff(arr): + return arr[1] - arr[0], arr[3] - arr[2] + + def find_ratio(delta, reference=5): + return max(abs(reference / delta[0]), abs(reference / delta[1])) + + extent = self._ax.get_extent(crs=ccrs.PlateCarree()) + ratio = find_ratio(diff(extent)) + new_extent = extent + np.array([-1, 1, -1, 1]) * ratio + self._ax.set_extent(new_extent, crs=ccrs.PlateCarree()) + @TimeTrackingWrapper class PlotConditionalQuantiles(AbstractPlotClass):