From 3b1f642b8b24ead95d8a2df3ade4b8974c2cb92b Mon Sep 17 00:00:00 2001 From: silencesoup Date: Wed, 15 Jan 2025 16:31:35 +0800 Subject: [PATCH 1/2] fix a bug and accelerate for plot --- hydroutils/hydro_plot.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hydroutils/hydro_plot.py b/hydroutils/hydro_plot.py index fe99d26..878e76d 100644 --- a/hydroutils/hydro_plot.py +++ b/hydroutils/hydro_plot.py @@ -1369,10 +1369,13 @@ def plot_rainfall_runoff( ax.set_ylim(ax.get_ylim()[0], ax.get_ylim()[1] * 1.2) # Create second axes, in order to get the bars from the top you can multiply by -1 ax2 = ax.twinx() - ax2.bar(tt, -p, color="b") + # ax2.bar(tt, -p, color="b") + # ax2.fill_between(tt, 0, -p, step="mid", color="b", alpha=0.5) + ax2.plot(tt, -p, color="b", alpha=0.7, linewidth=1.5) # Now need to fix the axis labels - max_pre = max(p) + # max_pre = max(p) + max_pre = p.max().item() ax2.set_ylim(-max_pre * 5, 0) y2_ticks = np.arange(0, max_pre, prcp_interval) y2_ticklabels = [str(i) for i in y2_ticks] @@ -1390,7 +1393,7 @@ def plot_rainfall_runoff( # https://github.com/matplotlib/matplotlib/issues/12318 ax.tick_params(axis="x", labelsize=16) ax.tick_params(axis="y", labelsize=16) - ax.legend(bbox_to_anchor=(0.01, 0.9), loc="upper left", fontsize=16) + ax.legend(bbox_to_anchor=(0.01, 0.85), loc="upper left", fontsize=16) ax.grid() return fig, ax From 43290ae53085fb2b5ca53dd711d88831ce24a03c Mon Sep 17 00:00:00 2001 From: silencesoup Date: Wed, 15 Jan 2025 16:35:42 +0800 Subject: [PATCH 2/2] fix a bug in plot --- hydroutils/hydro_plot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hydroutils/hydro_plot.py b/hydroutils/hydro_plot.py index 878e76d..b0a5a9a 100644 --- a/hydroutils/hydro_plot.py +++ b/hydroutils/hydro_plot.py @@ -1370,8 +1370,8 @@ def plot_rainfall_runoff( # Create second axes, in order to get the bars from the top you can multiply by -1 ax2 = ax.twinx() # ax2.bar(tt, -p, color="b") - # ax2.fill_between(tt, 0, -p, step="mid", color="b", alpha=0.5) - ax2.plot(tt, -p, color="b", alpha=0.7, linewidth=1.5) + ax2.fill_between(tt, 0, -p, step="mid", color="b", alpha=0.5) + # ax2.plot(tt, -p, color="b", alpha=0.7, linewidth=1.5) # Now need to fix the axis labels # max_pre = max(p)