diff options
Diffstat (limited to 'finance/visualize.py')
-rw-r--r-- | finance/visualize.py | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/finance/visualize.py b/finance/visualize.py index a13ac22..2c70f59 100644 --- a/finance/visualize.py +++ b/finance/visualize.py @@ -8,19 +8,26 @@ def display( simulated: list[tuple[datetime, Decimal]], measured: list[tuple[datetime, Decimal]], ) -> None: - matplotlib.pyplot.plot( - [i[0] for i in simulated], # type: ignore - [float(i[1]) for i in simulated], - label="Simulated", - ) - matplotlib.pyplot.plot( - [i[0] for i in measured], # type: ignore - [float(i[1]) for i in measured], - label="Measured", - marker="x", - linestyle="None", - ) - matplotlib.pyplot.xlabel("Time") matplotlib.pyplot.ylabel("Money") + matplotlib.pyplot.xlabel("Time") + + plot(data=simulated, label="Simulated") + plot(data=measured, label="Measured", marker=".", linestyle="none") matplotlib.pyplot.legend() + matplotlib.pyplot.show() + + +def plot( + data: list[tuple[datetime, Decimal]], + label: str, + marker: str = "", + linestyle: str = "solid", +) -> None: + matplotlib.pyplot.plot( + [i[0] for i in data], # type: ignore + [float(i[1]) for i in data], + label=label, + marker=marker, + linestyle=linestyle, + ) |