-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/USEPA/pybeepop
- Loading branch information
Showing
10 changed files
with
240 additions
and
327 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
example_beepop_results.csv | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" | ||
plots.py - Plotting Functions for PyBeePop+ | ||
""" | ||
|
||
import pandas as pd | ||
import matplotlib.pyplot as plt | ||
import matplotlib.dates as mdates | ||
|
||
|
||
def plot_timeseries(output=None, columns=[]): | ||
"""Function to plot a BeePop+ output as a time series. | ||
Args: | ||
output (DatFrame, optional): DataFrame of pybeepop+ model run output. Defaults to None. | ||
columns (list, optional): List of column names to plot (as strings). Defaults to ["Colony Size", "Adult Workers", "Capped Worker Brood", "Worker Larvae", "Worker Eggs"]. | ||
Returns: | ||
Matplotlib Axes object: A Matploitlib Axes object for further customization. | ||
""" | ||
if (output is not None) and columns: | ||
output_trimmed = output.iloc[1:, :].set_index("Date") # drop 'Initial' row | ||
output_trimmed.index = pd.DatetimeIndex( | ||
output_trimmed.index | ||
) # convert Date column to DateTimeIndex | ||
fig, ax = plt.subplots() | ||
for column in columns: | ||
ax.plot( | ||
output_trimmed.index.to_numpy(), output_trimmed[column].to_numpy(), label=column | ||
) | ||
ax.legend() | ||
ax.xaxis.set_major_formatter( | ||
mdates.ConciseDateFormatter(ax.xaxis.get_major_locator()) | ||
) # format date axis | ||
plt.show() | ||
return ax |
Oops, something went wrong.