-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
30 lines (23 loc) · 933 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import click
import numpy as np
from pandas import read_csv
import matplotlib.pyplot as plt
@click.command(context_settings=dict(help_option_names=['-h', '--help']))
@click.option('--csv', '-c', type=str, help='CSV file from https://www.ksh.hu/stadat_files/nep/en/nep0065.html in CSV format', required=True)
def do_plotting(csv):
df = read_csv(csv, parse_dates=['date'])
dates = df["date"]
df = df.drop(columns=["date"])
age_intervals = list(df.columns)
normalized_df = (df-df.mean())#/df.std()
# we are assuming dates are ordered
plt.pcolormesh(normalized_df.T,cmap=plt.cm.get_cmap('gnuplot'))
c = np.arange(1,len(dates)+1,52)
x_dates = dates[c]
plt.xticks(c, x_dates.dt.strftime("%Y"), rotation='vertical')
plt.yticks(np.arange(0.5, len(age_intervals), 1), age_intervals)
plt.colorbar()
plt.savefig("image.png")
plt.show()
if __name__ == "__main__":
do_plotting()