Skip to content

Fix to global plots #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions csep/utils/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ def plot_catalog(catalog, ax=None, show=False, extent=None, set_global=False, pl
except AttributeError:
pass

if extent is None:
if extent is None and not set_global:
dh = (bbox[1] - bbox[0]) / 20.
dv = (bbox[3] - bbox[2]) / 20.
extent = [bbox[0] - dh, bbox[1]+dh, bbox[2] -dv, bbox[3] + dv]
Expand All @@ -749,13 +749,14 @@ def plot_catalog(catalog, ax=None, show=False, extent=None, set_global=False, pl

if set_global:
ax.set_global()
region_border = False
else:
ax.set_extent(extents=extent, crs=ccrs.PlateCarree()) # Defined extent always in lat/lon

# Basemap plotting
ax = plot_basemap(basemap, extent, ax=ax, coastline=coastline, borders=borders, tile_scaling=tile_scaling,
linecolor=linecolor, linewidth=linewidth, projection=projection, apprx=apprx,
central_latitude=central_latitude)
central_latitude=central_latitude, set_global=set_global)

# Scaling function
mw_range = [min(catalog.get_magnitudes()), max(catalog.get_magnitudes())]
Expand Down Expand Up @@ -859,7 +860,7 @@ def plot_spatial_dataset(gridded, region, ax=None, show=False, extent=None, set_
"""
# Get spatial information for plotting
bbox = region.get_bbox()
if extent is None:
if extent is None and not set_global:
extent = [bbox[0], bbox[1], bbox[2] + region.dh, bbox[3] + region.dh]

# Retrieve plot arguments
Expand Down Expand Up @@ -907,13 +908,14 @@ def plot_spatial_dataset(gridded, region, ax=None, show=False, extent=None, set_

if set_global:
ax.set_global()
region_border = False
else:
ax.set_extent(extents=extent, crs=ccrs.PlateCarree()) # Defined extent always in lat/lon

# Basemap plotting
ax = plot_basemap(basemap, extent, ax=ax, coastline=coastline, borders=borders,
linecolor=linecolor, linewidth=linewidth, projection=projection, apprx=apprx,
central_latitude=central_latitude, tile_scaling=tile_scaling)
central_latitude=central_latitude, tile_scaling=tile_scaling, set_global=set_global)

## Define colormap and transparency function
if isinstance(cmap, str) or not cmap:
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/plot_customizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
# We define the arguments and a global projection, centered at $lon=-180$

plot_args = {'figsize': (10,6), 'coastline':True, 'feature_color':'black',
'projection': cartopy.crs.Robinson(central_longitude=-180.0),
'projection': cartopy.crs.Robinson(central_longitude=-179.0),
'title': forecast.name, 'grid_labels': False,
'cmap': 'magma',
'clabel': r'$\log_{10}\lambda\left(M_w \in [{%.2f},\,{%.2f}]\right)$ per '
Expand Down