-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgs2hbarm.py
66 lines (47 loc) · 1.34 KB
/
gs2hbarm.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import gspread
import pandas as pd
import matplotlib.pyplot as plt
gc = gspread.service_account()
sh = gc.open('wp-ja-2024-25')
# gc = gspread.oauth()
# sh = gc.open('wp-ja-2024-25')
# Checking connection
# print(sh.worksheet("min_day").get('H1:AE1'))
# print(sh.worksheet("min_day").get('H733:AE733'))
"""
Plot cumulative hours per project from Google Sheet workbook as horizontal bar plot.
Must authorize access to Google Sheets and Google Drive first time.
This authorization is done only once.
Blaine Mooers and OU Board of Regents
OUHSC
2024 January 25
"""
# Fetch the project names to plotted on Y-axis.
P = sh.worksheet("min_day").get('I1:AE1')
projects = [
x
for xs in P
for x in xs
]
# Minutes were converted to hours in the spreadsheet.
H = sh.worksheet("min_day").get('I733:AE733')
# We get a list of lists of strings from gspread.
# We have to flatten to a list.
hours = [
x
for xs in H
for x in xs
]
# Convert the strings in our list into floats.
float_list = list(map(float, hours))
# plot y,x
plt.barh(projects, float_list)
# setting x-label as pen sold
plt.xlabel("Hours")
# setting y_label as price
plt.ylabel("Project Name")
plt.rcParams.update({'font.size': 8})
# If project name is long, shift the plot frame to the right.
plt.subplots_adjust(left=0.28)
plt.show()
#plt.savefig('gs2barh.pdf', dpi=100)