forked from aqeelanwar/StatTheGit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aux_functions.py
62 lines (53 loc) · 1.71 KB
/
aux_functions.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
import os
import plotly.graph_objects as go
import chart_studio.plotly as py
from plotly.subplots import make_subplots
import plotly
plotly.io.orca.config.executable="/usr/local/bin/orca"
import plotly.io._orca
import retrying
unwrapped = plotly.io._orca.request_image_with_retrying.__wrapped__
wrapped = retrying.retry(wait_random_min=1000)(unwrapped)
plotly.io._orca.request_image_with_retrying = wrapped
ORANGE = "#DD8047"
BLUE = "94B6D2"
GREEN = "#A5AB81"
YELLOW = "#D8B25C"
def plot_stat(xs, ys, repo_names, title="Shamir-Lab", data="Clones", type="offline", figures_folder=""):
try:
os.makedirs(figures_folder)
except Exception as e:
pass
print("start start plotting...")
fig = make_subplots(specs=[[{"secondary_y": True}]])
for x,y,repo_name in zip(xs, ys, repo_names):
fig.add_trace(
go.Scatter(
x=x,
y=y,
mode="lines",
name=repo_name,
# color="darkred",
line=dict(width=3),
marker=dict(size=10),
),
secondary_y=False,
)
fig.update_layout(
title=f'{title} (n={len(repo_names)}); {data}',
font=dict(color="#7f7f7f"),
autosize=True,
legend=dict(x=0, y=1, orientation="v"),
margin=dict(l=0, r=0, t=40, b=30),
)
if type == "offline":
# fig.write_image("summary.png")
fig.write_html(os.path.join(figures_folder, f"git_stat_{title}_{data}.html"))
print("saved summary!")
elif type == "online":
url = py.plot(fig, filename=repo_name, sharing="public")
print(url)
def display_StatTheGit():
with open("display.txt", "r") as file:
for line in file:
print(line, end="")