Skip to content

Commit ff0e4da

Browse files
committed
simplified calculation for the aspect scaling
added missing else statement to handle set_global flag in plot_basemap
1 parent a604a98 commit ff0e4da

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

csep/utils/plots.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -577,15 +577,21 @@ def plot_basemap(basemap, extent, ax=None, coastline=True, borders=False, linec
577577
578578
"""
579579
if ax is None:
580-
fig = pyplot.figure()
581-
ax = fig.add_subplot(111, projection=projection)
582580
if apprx:
581+
projection = ccrs.PlateCarree()
582+
fig = pyplot.figure()
583+
ax = fig.add_subplot(111, projection=projection)
583584
# Re-aspect plot (only for plain matplotlib plots, or when using PlateCarree)
584585
LATKM = 110.574
585-
ax.set_aspect(1 / (LATKM / 111.320 * numpy.cos(numpy.deg2rad(central_latitude))))
586+
ax.set_aspect(111.320 * numpy.cos(numpy.deg2rad(central_latitude)) / LATKM)
587+
else:
588+
fig = pyplot.figure()
589+
ax = fig.add_subplot(111, projection=projection)
586590

587591
if set_global:
588592
ax.set_global()
593+
else:
594+
ax.set_extent(extents=extent, crs=ccrs.PlateCarree())
589595

590596
try:
591597
# Set adaptive scaling
@@ -697,7 +703,7 @@ def plot_catalog(catalog, ax=None, show=False, extent=None, set_global=False, pl
697703
pass
698704

699705
if extent is None:
700-
dh = (bbox[1] - bbox[0])/20.
706+
dh = (bbox[1] - bbox[0]) / 20.
701707
dv = (bbox[3] - bbox[2]) / 20.
702708
extent = [bbox[0] - dh, bbox[1]+dh, bbox[2] -dv, bbox[3] + dv]
703709

@@ -713,8 +719,6 @@ def plot_catalog(catalog, ax=None, show=False, extent=None, set_global=False, pl
713719
if ax is None:
714720
fig = pyplot.figure(figsize=figsize)
715721
ax = fig.add_subplot(111, projection=projection)
716-
else:
717-
fig = ax.get_figure()
718722

719723
if set_global:
720724
ax.set_global()

0 commit comments

Comments
 (0)