Skip to content

Commit 167d5f6

Browse files
committed
Added bar chart with Matplotlib
1 parent bba18f8 commit 167d5f6

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
venv/
2+
*.csv

ev_counts.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
rows.append(row)
1111
csv_file.close()
1212

13-
years = range(2016, 2022)
13+
years = range(2016, 2023)
1414

1515
counts = {} # make empty dictionary for yearly counts
1616

@@ -28,3 +28,17 @@
2828
for year in years:
2929
print(f'{year}: {counts[year]:>5}')
3030
print(f'Yhteensä: {len(rows)}')
31+
32+
# Tee ennen tätä virtuaaliympäristö samaan hakemistoon
33+
# missä projekti on: `python3 -m venv venv`.
34+
# Aktivoi virtuaaliympäristö: `source venv/bin/activate`
35+
# Asenna sitten Matplotlib: `pip install matplotlib`.
36+
# Kun olet lopettanut projektin työstämisen,
37+
# anna komento `deactivate`.
38+
39+
import matplotlib.pyplot as plt
40+
41+
values = [counts[k] for k in sorted(list(counts.keys()))]
42+
plt.bar(sorted(list(counts.keys())), values,
43+
tick_label=sorted(list(counts.keys())))
44+
plt.show()

0 commit comments

Comments
 (0)