@@ -236,7 +236,7 @@ def coastdat_geoplot(results_df, conn, show_plot=True, legend_label=None,
236
236
237
237
def plot_histogram (calms , show_plot = True , legend_label = None , x_label = None ,
238
238
y_label = None , save_folder = 'Plots' , save_figure = True ,
239
- y_limit = None , x_limit = 1200 , bin_width = 50 , tick_freq = 100 ,
239
+ y_limit = None , x_limit = None , bin_width = 50 , tick_freq = 100 ,
240
240
filename_plot = 'plot_histogram.png' ):
241
241
"""
242
242
calms should have the coastdat region gid as index and the values
@@ -247,11 +247,15 @@ def plot_histogram(calms, show_plot=True, legend_label=None, x_label=None,
247
247
calms_sorted = np .sort (np .array (calms ['results' ]))
248
248
# plot
249
249
fig = plt .figure ()
250
- plt .hist (calms_sorted , bins = np .arange (0 , x_limit + 1 , bin_width ),
250
+ if x_limit :
251
+ x_max = x_limit
252
+ else :
253
+ x_max = max (calms_sorted )
254
+ plt .hist (calms_sorted , bins = np .arange (0 , x_max + 1 , bin_width ),
251
255
normed = False )
252
256
plt .xlabel (x_label )
253
257
plt .ylabel (y_label )
254
- plt .xticks (np .arange (0 , x_limit + 1 , tick_freq ))
258
+ plt .xticks (np .arange (0 , x_max + 1 , tick_freq ))
255
259
if y_limit :
256
260
plt .ylim (ymax = y_limit )
257
261
if x_limit :
0 commit comments