-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72e2a46
commit 46b83b3
Showing
3 changed files
with
56 additions
and
22 deletions.
There are no files selected for viewing
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
Empty file.
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,42 @@ | ||
from datetime import datetime | ||
|
||
import matplotlib.pyplot as plt | ||
from matplotlib.axes import Axes | ||
from matplotlib.figure import Figure | ||
|
||
|
||
def lineplot_timeseries( | ||
data: list[float], | ||
dates_data: list[datetime | None], | ||
fig_size: tuple[int, int] = (10, 6), | ||
save_path: str | None = None, | ||
label: str = "", | ||
xlabel: str = "", | ||
ylabel: str = "", | ||
title: str = "", | ||
color: str = "blue", | ||
) -> tuple[Figure, Axes]: | ||
fig, ax = plt.subplots(1, 1, figsize=fig_size) | ||
# ax = subplots[0] | ||
if any(value is None for value in dates_data): | ||
ax.plot(data, label=label, color=color) | ||
else: | ||
ax.plot( | ||
dates_data, # type: ignore | ||
data, | ||
label=label, | ||
color=color, | ||
) | ||
|
||
ax.set_title(title) | ||
ax.set_xlabel(xlabel) | ||
ax.set_ylabel(ylabel) | ||
ax.legend() | ||
plt.grid(True) | ||
|
||
if save_path: | ||
fig.savefig(save_path) | ||
else: | ||
plt.show() | ||
|
||
return fig, ax |