diff options
author | xengineering <me@xengineering.eu> | 2024-09-08 11:37:41 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2024-09-08 17:21:32 +0200 |
commit | 2560d862d5019db1b103a6e6a9c14dfa66afe78d (patch) | |
tree | 79da747d7cda3bc61d80d9cfe11ed0259d78f2f3 /finance | |
parent | 599ef8b119d0b37791b53d9f3a14eeaa658421b1 (diff) | |
download | finance-py-2560d862d5019db1b103a6e6a9c14dfa66afe78d.tar finance-py-2560d862d5019db1b103a6e6a9c14dfa66afe78d.tar.zst finance-py-2560d862d5019db1b103a6e6a9c14dfa66afe78d.zip |
Move display() to finance.visualize.py
Diffstat (limited to 'finance')
-rw-r--r-- | finance/flow.py | 14 | ||||
-rw-r--r-- | finance/visualize.py | 16 |
2 files changed, 16 insertions, 14 deletions
diff --git a/finance/flow.py b/finance/flow.py index bc2ee0a..4cf68db 100644 --- a/finance/flow.py +++ b/finance/flow.py @@ -3,8 +3,6 @@ from datetime import datetime from decimal import Decimal from typing import Generator -import matplotlib.pyplot - @dataclasses.dataclass(kw_only=True, frozen=True) class Flow: @@ -66,15 +64,3 @@ def simulate( values.append(value) return (dates, values) - - -def display(data: tuple[list[datetime], list[Decimal]]) -> None: - matplotlib.pyplot.plot( - list(data[0]), # type: ignore - [float(i) for i in data[1]], - label="Money", - ) - matplotlib.pyplot.xlabel("Time") - matplotlib.pyplot.legend() - matplotlib.pyplot.xticks(rotation=45) - matplotlib.pyplot.show() diff --git a/finance/visualize.py b/finance/visualize.py new file mode 100644 index 0000000..e6d609a --- /dev/null +++ b/finance/visualize.py @@ -0,0 +1,16 @@ +from datetime import datetime +from decimal import Decimal + +import matplotlib.pyplot + + +def display(data: tuple[list[datetime], list[Decimal]]) -> None: + matplotlib.pyplot.plot( + list(data[0]), # type: ignore + [float(i) for i in data[1]], + label="Money", + ) + matplotlib.pyplot.xlabel("Time") + matplotlib.pyplot.legend() + matplotlib.pyplot.xticks(rotation=45) + matplotlib.pyplot.show() |