Skip to content

Commit

Permalink
first try adding watches disclaimer to plot
Browse files Browse the repository at this point in the history
  • Loading branch information
ehinman committed Sep 29, 2023
1 parent b559c93 commit a7693cb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions hyswap/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def plot_raster_hydrograph(df_formatted, ax=None,
def plot_duration_hydrograph(percentiles_by_day, df, data_col, doy_col,
pct_list=[0, 5, 10, 25, 75, 90, 95, 100],
data_label=None, ax=None,
disclaimer=False,
title="Duration Hydrograph",
ylab="Discharge, in Cubic Feet per Second",
xlab="Month", colors=None, **kwargs):
Expand All @@ -259,6 +260,11 @@ def plot_duration_hydrograph(percentiles_by_day, df, data_col, doy_col,
ax : matplotlib.axes.Axes, optional
Axes to plot on. If not provided, a new figure and axes will be
created.
disclaimer : bool, optional
If True, displays the disclaimer 'For some streams, flow
statistics may have been computed from mixed regulated
and unregulated flows; this can affect depictions of flow
conditions.' below the x-axis.
title : str, optional
Title for the plot. If not provided, the default title will be
'Duration Hydrograph'.
Expand Down Expand Up @@ -313,6 +319,11 @@ def plot_duration_hydrograph(percentiles_by_day, df, data_col, doy_col,
label = df[data_col].name
else:
label = data_label
# Add disclaimer if True
if disclaimer is True:
txt = 'For some streams, flow statistics may have been computed from mixed regulated \nand unregulated flows; this can affect depictions of flow conditions.' # noqa: E501
else:
txt = ''
# get colors
if colors is None:
colors = ["#e37676", "#e8c285", "#dbf595", "#a1cc9f",
Expand Down Expand Up @@ -354,6 +365,8 @@ def plot_duration_hydrograph(percentiles_by_day, df, data_col, doy_col,
ax.set_ylabel(ylab)
ax.set_yscale("log")
ax.set_title(title)
# disclaimer
ax.text(0.5, 0.05, txt, ha='center', color='red')
# get y-axis ticks and convert to comma-separated strings
yticks = ax.get_yticks()
yticklabels = [f'{int(y):,}' for y in yticks]
Expand Down

0 comments on commit a7693cb

Please sign in to comment.