psalama commited on
Commit
2ac7da0
·
1 Parent(s): b939fb6

Modularize python code

Browse files
Files changed (1) hide show
  1. plot.py +19 -0
plot.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import matplotlib.pyplot as plt
2
+ import geopandas as gpd
3
+
4
+ # all plotting functions
5
+ def create_plot(filename, extent, *gdfs): # takes in unlimited number of gdfs
6
+ fig, ax = plt.subplots(figsize=(10, 8)) #Sets image size by width & height (in inches)
7
+
8
+ colors = ['tan', 'mediumseagreen', 'thistle', 'lightcoral', 'sienna', 'yellow'] # Extend/improve this list as needed
9
+
10
+ for idx, gdf in enumerate(gdfs):
11
+ gdf.plot(ax=ax, color=colors[idx % len(colors)]) # Cycle through colors
12
+
13
+ ax.set_xlim(extent[0], extent[2])
14
+ ax.set_ylim(extent[1], extent[3])
15
+
16
+ # Hide axes
17
+ ax.axis('off')
18
+
19
+ plt.savefig(filename, bbox_inches='tight', pad_inches=0) # remove padding