Skip to content

Fixed catalog plotting options. #134

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 2 commits into from
Jul 24, 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
2 changes: 1 addition & 1 deletion csep/core/catalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ def plot(self, ax=None, show=False, extent=None, set_global=False, plot_args=Non
'legend_loc': 3,
'figsize': (8, 8),
'title': self.name,
'mag_ticks': [4.0, 5.0, 6.0, 7.0]
'mag_ticks': False
}
# Plot the region border (if it exists) by default
try:
Expand Down
15 changes: 11 additions & 4 deletions csep/utils/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ def plot_basemap(basemap, extent, ax=None, coastline=True, borders=False, linec
if grid:
gl = ax.gridlines(draw_labels=grid_labels, alpha=0.5)
gl.right_labels = False
gl.top_labels = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER

Expand Down Expand Up @@ -751,12 +752,16 @@ def size_map(markersize, values, scale):
# Legend
if legend:
if not mag_ticks:
mag_ticks = numpy.round(numpy.linspace(mw_range[0], mw_range[1], 4), 1)
mag_ticks = numpy.linspace(mw_range[0], mw_range[1], 4)
else:
if not numpy.all([ i >= mw_range[0] and i <= mw_range[1] for i in mag_ticks]):
print("Magnitude ticks do not lie within the catalog magnitude range")

handles, labels = scatter.legend_elements(prop="sizes",
num=list(size_map(markersize, mag_ticks, mag_scale)),
alpha=0.3)
ax.legend(handles, mag_ticks,
loc=legend_loc, title=r"Magnitudes",title_fontsize=16,
ax.legend(handles, numpy.round(mag_ticks, 1),
loc=legend_loc, title=r"Magnitudes", title_fontsize=16,
labelspacing=labelspacing, handletextpad=5, framealpha=False)

if region_border:
Expand All @@ -770,6 +775,7 @@ def size_map(markersize, values, scale):
if grid:
gl = ax.gridlines(draw_labels=grid_labels, alpha=0.5)
gl.right_labels = False
gl.top_labels = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER

Expand Down Expand Up @@ -827,7 +833,7 @@ def plot_spatial_dataset(gridded, region, ax=None, show=False, extent=None, set_
plot_args = plot_args or {}
# figure and axes properties
figsize = plot_args.get('figsize', None)
title = plot_args.get('title', 'Spatial Dataset')
title = plot_args.get('title', None)
title_size = plot_args.get('title_size', None)
filename = plot_args.get('filename', None)
# cartopy properties
Expand Down Expand Up @@ -901,6 +907,7 @@ def plot_spatial_dataset(gridded, region, ax=None, show=False, extent=None, set_
if grid:
gl = ax.gridlines(draw_labels=grid_labels, alpha=0.5)
gl.right_labels = False
gl.top_labels = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER

Expand Down