@@ -92,7 +92,7 @@ def out_polygon(self):
92
92
raise Exception ("Empty swath profile, please try reset arguments." )
93
93
94
94
poly = Polygon (coords )
95
- return poly . buffer ( 0.001 )
95
+ return poly
96
96
97
97
def out_polylines (self ):
98
98
"Return a shapely polyline object"
@@ -155,9 +155,7 @@ def profile_stat(self):
155
155
156
156
return [min_z , max_z , mean_z , q1 , q3 ]
157
157
158
- def profile_plot (self , ax = None , color = 'navy' ,
159
- p_coords = None , p_marker = "o" , p_size = 1 ,
160
- p_color = 'C3' , p_label = None ):
158
+ def profile_plot (self , ax = None , color = 'navy' , p_coords = None , ** kwargs ):
161
159
d = np .linspace (0 , self .radial_stepsize * self .dat_steps , self .dat_steps ,
162
160
endpoint = True )
163
161
stat = self .profile_stat ()
@@ -180,17 +178,15 @@ def profile_plot(self, ax=None, color='navy',
180
178
dist_array = np .append (dist_array , dist )
181
179
elev_array = np .append (elev_array , elev )
182
180
183
- ax .scatter (dist_array , elev_array ,
184
- s = p_size , marker = p_marker , color = p_color , label = p_label )
181
+ ax .scatter (dist_array , elev_array , ** kwargs )
185
182
186
183
ax .set_xlabel ("Distance" )
187
184
ax .set_ylabel ("Elevation" )
188
185
ax .legend ()
189
186
plt .tight_layout ()
190
-
191
187
return ax
192
188
193
- def slice_plot (self , angle ):
189
+ def slice_plot (self , angle , ax = None ):
194
190
"""Plot cross-section of swath data.
195
191
196
192
:param angle: the angle of cross-section wrt horizontal line
@@ -211,13 +207,16 @@ def slice_plot(self, angle):
211
207
d_temp = np .sqrt ((point [0 ]- points [0 ][0 ])** 2
212
208
+ (point [1 ]- points [0 ][1 ])** 2 )
213
209
d .append (d_temp )
210
+
211
+ if ax is None :
212
+ fig , ax = plt .subplots ()
214
213
215
- fig , ax = plt .subplots ()
216
214
ax .plot (d , values )
217
215
ax .set_xlabel ("Distance to center" )
218
216
ax .set_ylabel ("Elevation" )
219
217
ax .grid ()
220
218
plt .tight_layout ()
219
+ return ax
221
220
222
221
def slice_polyline (self , angle ):
223
222
"""Return the polyline of cross-section
@@ -238,18 +237,21 @@ def slice_polyline(self, angle):
238
237
return LineString (line )
239
238
240
239
241
- def hist (self , bins = 50 ):
240
+ def hist (self , bins = 50 , ax = None ):
242
241
"Return a histogram plot"
243
242
dat = np .hstack (self .dat )
244
-
245
- fig , ax = plt .subplots ()
246
- ax .hist (dat , bins = bins , histtype = 'stepfilled' , alpha = 1 , normed = True )
243
+
244
+ if ax is None :
245
+ fig , ax = plt .subplots ()
246
+
247
+ ax .hist (dat , bins = bins , histtype = 'stepfilled' , alpha = 1 , density = True )
247
248
ax .set_xlabel ("Elevation" )
248
249
ax .set_ylabel ("PDF" )
249
250
ax .grid ()
250
251
plt .tight_layout ()
252
+ return ax
251
253
252
- def slice_hist (self , angle , bins = 10 ):
254
+ def slice_hist (self , angle , bins = 10 , ax = None ):
253
255
"""Plot the histogram of slice
254
256
255
257
:param angle: angle of cross-section wrt horizontal line
@@ -265,12 +267,15 @@ def slice_hist(self, angle, bins=10):
265
267
ng_ind = np .abs (sector - angle ).argmin ()
266
268
dat = self .dat [ng_ind ]
267
269
268
- fig , ax = plt .subplots ()
269
- ax .hist (dat , bins = bins , histtype = 'stepfilled' , alpha = 1 , normed = True )
270
+ if ax is None :
271
+ fig , ax = plt .subplots ()
272
+
273
+ ax .hist (dat , bins = bins , histtype = 'stepfilled' , alpha = 1 , density = True )
270
274
ax .set_xlabel ("Elevation" )
271
275
ax .set_ylabel ("PDF" )
272
276
ax .grid ()
273
277
plt .tight_layout ()
278
+ return ax
274
279
275
280
276
281
0 commit comments