Graph Machine Learning
AnemoI
English
aifs-single / plotting_utils.py
anaprietonem's picture
Create plotting_utils.py
9cacbc2 verified
raw
history blame
956 Bytes
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy
def map_scatter(lats, lons, data, proj=ccrs.PlateCarree(), mask_ocean=False, region=None, axes=None,plot_title=None,cmap_label=None,**kwargs):
if axes is None:
fig, axes = plt.subplots(subplot_kw={'projection': proj}, figsize=(16,6))
axes.coastlines()
axes.gridlines()
sc = axes.scatter(
x=lons,
y=lats,
c=data,
transform=ccrs.PlateCarree(),
s=1,
**kwargs,
)
plt.colorbar(sc,label=cmap_label)
plt.title(plot_title)
# Add title and labels
if mask_ocean:
axes.add_feature(cartopy.feature.OCEAN, zorder=1, color="w")
gl = axes.gridlines(draw_labels=True, alpha=.3, color='grey',
linewidth=0.5,linestyle ='-',
x_inline= False, y_inline=False)
gl.n_steps = 100
gl.top_labels = False
gl.right_labels = False
return None