Skip to content

Commit

Permalink
add legend to plots
Browse files Browse the repository at this point in the history
  • Loading branch information
erexer committed Sep 4, 2024
1 parent dde3e32 commit a9ca83b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 29 deletions.
23 changes: 13 additions & 10 deletions docs/source/A3_plotting_code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,24 @@ ___________________________________________
"""
# set plot style
plt.style.use('seaborn-white')
plt.style.use("seaborn-v0_8-white")
# set up figure
fig, ax = plt.subplots(figsize=figsize)
# plot observed streamflow
ax.plot(range(0, len(df['Strmflw'])), df['Strmflw'], color='pink')
ax.plot(range(0, len(df["Strmflw"])), df["Strmflw"], color="pink", label="Observed Streamflow")
# plot simulated streamflow
ax.plot(range(0, len(df['Strmflw'])), hymod_dict['Q'], color='black')
ax.plot(range(0, len(df["Strmflw"])), hymod_dict["Q"], color="black", label="Simulated Streamflow")
# set axis labels
ax.set_ylabel('Streamflow($m^3/s$)')
ax.set_xlabel('Days')
ax.set_ylabel("Streamflow($m^3/s$)")
ax.set_xlabel("Days")
ax.legend()
# set plot title
plt.title('Observed vs. Simulated Streamflow')
plt.title("Observed vs. Simulated Streamflow")
return ax
Expand Down Expand Up @@ -82,17 +83,19 @@ _____________________________________________
fig, ax = plt.subplots(figsize=figsize)
# set labels
ax.set_xlabel('Days')
ax.set_ylabel('Flow Discharge (m^3/s)')
ax.set_xlabel("Days")
ax.set_ylabel("Flow Discharge (m^3/s)")
# plots all simulated streamflow cases under different sample sets
for i in df_sim.columns:
plt.plot(month_list, df_sim[i], color="pink", alpha=0.2)
ax.plot([], [], label="Sensitivity Analysis Streamflow", color="pink")
# plot observed streamflow
plt.plot(month_list, df_obs['Strmflw'], color="black")
plt.plot(month_list, df_obs["Strmflw"], color="black", label="Observed Streamflow")
plt.title('Observed vs. Sensitivity Analysis Outputs')
plt.title("Observed vs. Sensitivity Analysis Outputs")
ax.legend(loc="upper right")
return ax
Expand Down
Binary file modified docs/source/_static/hymod1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/_static/hymod2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/_static/hymod3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 7 additions & 3 deletions msdbook/hymod.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ def plot_observed_vs_simulated_streamflow(df, hymod_dict, figsize=[12, 6]):
fig, ax = plt.subplots(figsize=figsize)

# plot observed streamflow
ax.plot(range(0, len(df["Strmflw"])), df["Strmflw"], color="pink")
ax.plot(range(0, len(df["Strmflw"])), df["Strmflw"], color="pink", label="Observed Streamflow")

# plot simulated streamflow
ax.plot(range(0, len(df["Strmflw"])), hymod_dict["Q"], color="black")
ax.plot(
range(0, len(df["Strmflw"])), hymod_dict["Q"], color="black", label="Simulated Streamflow"
)

# set axis labels
ax.set_ylabel("Streamflow($m^3/s$)")
Expand Down Expand Up @@ -69,11 +71,13 @@ def plot_observed_vs_sensitivity_streamflow(df_obs, df_sim, figsize=[10, 4]):
# plots all simulated streamflow cases under different sample sets
for i in df_sim.columns:
plt.plot(month_list, df_sim[i], color="pink", alpha=0.2)
ax.plot([], [], label="Sensitivity Analysis Streamflow", color="pink")

# plot observed streamflow
plt.plot(month_list, df_obs["Strmflw"], color="black")
plt.plot(month_list, df_obs["Strmflw"], color="black", label="Observed Streamflow")

plt.title("Observed vs. Sensitivity Analysis Outputs")
ax.legend(loc="upper right")

return ax

Expand Down
32 changes: 16 additions & 16 deletions notebooks/hymod.ipynb

Large diffs are not rendered by default.

0 comments on commit a9ca83b

Please sign in to comment.