Skip to content

Commit 4f95ff9

Browse files
committed
X_lim = None possible
1 parent a286cdd commit 4f95ff9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

get_from_db.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def coastdat_geoplot(results_df, conn, show_plot=True, legend_label=None,
236236

237237
def plot_histogram(calms, show_plot=True, legend_label=None, x_label=None,
238238
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,
240240
filename_plot='plot_histogram.png'):
241241
"""
242242
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,
247247
calms_sorted = np.sort(np.array(calms['results']))
248248
# plot
249249
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),
251255
normed=False)
252256
plt.xlabel(x_label)
253257
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))
255259
if y_limit:
256260
plt.ylim(ymax=y_limit)
257261
if x_limit:

0 commit comments

Comments
 (0)