Graph Machine Learning
AnemoI
English
anaprietonem commited on
Commit
9cacbc2
1 Parent(s): 987b9ce

Create plotting_utils.py

Browse files
Files changed (1) hide show
  1. plotting_utils.py +31 -0
plotting_utils.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import matplotlib.pyplot as plt
3
+ import cartopy.crs as ccrs
4
+ import cartopy
5
+
6
+ def map_scatter(lats, lons, data, proj=ccrs.PlateCarree(), mask_ocean=False, region=None, axes=None,plot_title=None,cmap_label=None,**kwargs):
7
+ if axes is None:
8
+ fig, axes = plt.subplots(subplot_kw={'projection': proj}, figsize=(16,6))
9
+ axes.coastlines()
10
+ axes.gridlines()
11
+ sc = axes.scatter(
12
+ x=lons,
13
+ y=lats,
14
+ c=data,
15
+ transform=ccrs.PlateCarree(),
16
+ s=1,
17
+ **kwargs,
18
+ )
19
+ plt.colorbar(sc,label=cmap_label)
20
+ plt.title(plot_title)
21
+ # Add title and labels
22
+
23
+ if mask_ocean:
24
+ axes.add_feature(cartopy.feature.OCEAN, zorder=1, color="w")
25
+ gl = axes.gridlines(draw_labels=True, alpha=.3, color='grey',
26
+ linewidth=0.5,linestyle ='-',
27
+ x_inline= False, y_inline=False)
28
+ gl.n_steps = 100
29
+ gl.top_labels = False
30
+ gl.right_labels = False
31
+ return None