Add simple matplotlib graph
This commit is contained in:
parent
172920b594
commit
5ec1b1ca14
1 changed files with 11 additions and 5 deletions
|
@ -12,6 +12,8 @@ from pathlib import Path
|
||||||
import subprocess
|
import subprocess
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
|
import matplotlib.pyplot as plt # type: ignore
|
||||||
|
|
||||||
|
|
||||||
def grab_json_with_curl() -> str:
|
def grab_json_with_curl() -> str:
|
||||||
"""Run the curl command in a shell and grab the output as json."""
|
"""Run the curl command in a shell and grab the output as json."""
|
||||||
|
@ -65,14 +67,14 @@ def print_to_output(confirmed: int, today_confirmed_int: int,
|
||||||
"""Format the data for the i3block."""
|
"""Format the data for the i3block."""
|
||||||
|
|
||||||
if today_confirmed_int >= 0:
|
if today_confirmed_int >= 0:
|
||||||
today_confirmed = f"+{today_confirmed_int}"
|
today_confirmed = f"↑{today_confirmed_int}"
|
||||||
else:
|
else:
|
||||||
today_confirmed = f"{today_confirmed_int}"
|
today_confirmed = f"↓{today_confirmed_int}"
|
||||||
|
|
||||||
if today_deaths_int >= 0:
|
if today_deaths_int >= 0:
|
||||||
today_deaths = f"+{today_deaths_int}"
|
today_deaths = f"↑{today_deaths_int}"
|
||||||
else:
|
else:
|
||||||
today_deaths = f"{today_deaths_int}"
|
today_deaths = f"↓{today_deaths_int}"
|
||||||
|
|
||||||
output = f"{confirmed} ({today_confirmed}) ✝ {deaths} ({today_deaths})"
|
output = f"{confirmed} ({today_confirmed}) ✝ {deaths} ({today_deaths})"
|
||||||
|
|
||||||
|
@ -82,7 +84,11 @@ def print_to_output(confirmed: int, today_confirmed_int: int,
|
||||||
def generate_graph(data: List[int]) -> None:
|
def generate_graph(data: List[int]) -> None:
|
||||||
"""Generate a small graph based on the evolution of numbers in the list."""
|
"""Generate a small graph based on the evolution of numbers in the list."""
|
||||||
|
|
||||||
print("HELLO THERE")
|
print(data[0:20])
|
||||||
|
data = [number // 1000 for number in data]
|
||||||
|
X = range(len(data))
|
||||||
|
plt.plot(X, [data[i] for i in X])
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
|
|
Loading…
Add table
Reference in a new issue