-
Notifications
You must be signed in to change notification settings - Fork 4
/
changerates-plot.py
65 lines (48 loc) · 1.64 KB
/
changerates-plot.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
import pandas as pd
import pylab
import os
import sys
FONT = 16
def plot_rates(cmap):
df = pd.read_csv("changerates.csv")
df = df.set_index(["#date"])
ax = df.plot(cmap=cmap, fontsize=FONT)
ax.set_xlabel("date", fontsize=FONT)
ax.set_ylabel("chart changes", fontsize=FONT)
ax.set_title("Change rates of KubeApps Hub", fontsize=FONT)
ax.legend(fontsize=FONT)
pylab.setp(ax.xaxis.get_majorticklabels(), rotation=70)
pylab.tight_layout()
pylab.savefig("changerates-plot.png")
def plot_total(cmap):
df = pd.read_csv("changerates-total.csv", header=None, names=["#date", "total"])
df = df.set_index(["#date"])
dfuniq = None
if os.path.isfile("changerates-unique.csv"):
dfuniq = pd.read_csv("changerates-unique.csv")
dfuniq = dfuniq.set_index(["#date"])
ax = df.plot(cmap=cmap, ylim=[0, max(df["total"]) + 50], fontsize=FONT)
ax.set_xlabel("date", fontsize=FONT)
ax.set_ylabel("total charts", fontsize=FONT)
ax.set_title("Evolution of KubeApps Hub", fontsize=FONT)
ax.legend(fontsize=FONT)
if dfuniq is not None:
dfuniq.plot(cmap=cmap + "_r", ax=ax, fontsize=FONT)
pylab.setp(ax.xaxis.get_majorticklabels(), rotation=70)
pylab.tight_layout()
pylab.savefig("changerates-total-plot.png")
if __name__ == "__main__":
if len(sys.argv) not in (2, 3):
print(f"Syntax: {sys.argv[0]} <command> [<colourmap>]", file=sys.stderr)
print("Commands: rates, total / Colourmaps: e.g. gray, seismic", file=sys.stderr)
sys.exit(1)
command = sys.argv[1]
cmap = "gray"
if len(sys.argv) == 3:
cmap = sys.argv[2]
if command == "rates":
plot_rates(cmap)
elif command == "total":
plot_total(cmap)
else:
print("Unknown command.", file=sys.stderr)