-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_results.py
42 lines (33 loc) · 939 Bytes
/
plot_results.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from argparse import ArgumentParser, Namespace
from pathlib import Path
import matplotlib.pyplot as plt
import pandas as pd
def parse_args() -> Namespace:
parser = ArgumentParser(
"FortranSimpleModelPlot",
description="Generates a plot of the SEIRS model over time",
)
parser.add_argument(
"input",
type=Path,
help="The input .csv to plot",
)
parser.add_argument(
"-o",
"--output",
type=Path,
default="SEIRS.png",
help="Destination of the saved plot",
)
return parser.parse_args()
def plot(df: pd.DataFrame, output: Path) -> None:
for col in "SEIR":
plt.plot(df["time"], df[col], label=col)
plt.legend()
plt.xlabel("Time /years")
plt.ylabel("Population Fraction")
plt.savefig(output)
if __name__ == "__main__":
args = parse_args()
df = pd.read_csv(args.input)
plot(df, args.output)