Skip to content
Snippets Groups Projects
Commit ef14c014 authored by lukas leufen's avatar lukas leufen
Browse files

station map extent is now adjusted by itself

parent f31867ca
No related branches found
No related tags found
4 merge requests!136update release branch,!135Release v0.11.0,!127Resolve "moving station map",!119Resolve "Include advanced data handling in workflow"
Pipeline #41110 passed
...@@ -258,14 +258,28 @@ class PlotStationMap(AbstractPlotClass): ...@@ -258,14 +258,28 @@ class PlotStationMap(AbstractPlotClass):
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
fig = plt.figure(figsize=(10, 5)) fig = plt.figure(figsize=(10, 5))
self._ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree()) 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 = self._ax.gridlines(xlocs=range(0, 21, 5), ylocs=range(44, 59, 2), draw_labels=True)
self._gl.xformatter = LONGITUDE_FORMATTER self._gl.xformatter = LONGITUDE_FORMATTER
self._gl.yformatter = LATITUDE_FORMATTER self._gl.yformatter = LATITUDE_FORMATTER
self._draw_background() self._draw_background()
self._plot_stations(generators) self._plot_stations(generators)
self._adjust_extent()
plt.tight_layout() 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 @TimeTrackingWrapper
class PlotConditionalQuantiles(AbstractPlotClass): class PlotConditionalQuantiles(AbstractPlotClass):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment