-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_firefox_codebase.py
More file actions
70 lines (62 loc) · 1.84 KB
/
Copy pathplot_firefox_codebase.py
File metadata and controls
70 lines (62 loc) · 1.84 KB
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
67
68
69
70
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import yaml
import matplotlib as mpl
mpl.rcParams["svg.hashsalt"] = "42"
with open("plotting_config.yaml", "r") as fp:
config = yaml.safe_load(fp)
versions = pd.read_csv("data/firefox/firefox_versions.csv", nrows=11)
versions["date"] = pd.to_datetime(versions["date"], format="%Y-%m-%d")
result = {}
for i in versions["release"].tolist():
data = pd.read_csv(
f"data/firefox/ff{i}.txt",
sep=r"\s{2,}",
engine="python",
skiprows=3,
skipfooter=3,
names=["language", "files", "lines", "code", "comments", "blanks"],
)
result[i] = int(data["lines"].sum())
versions["lines"] = result.values()
versions["lines"] = round(versions["lines"] / 1000000, 2)
fig, ax = plt.subplots(figsize=(6, 5), layout="constrained", dpi=150)
ax.set_facecolor("none")
fig.set_facecolor("none")
sns.barplot(
versions.sort_values("date", ascending=True),
x="date",
y="lines",
ax=ax,
color="#FFE6CC",
)
for patch, ver in zip(
ax.patches, versions.sort_values("date", ascending=True)["release"]
):
patch.set_edgecolor("#D79B00")
patch.get_x()
ax.text(
patch.get_x() + patch.get_width() / 2,
2,
f"Firefox {ver}",
ha="center",
va="bottom",
rotation=90,
color="#D79B00",
fontsize=12,
fontweight="bold",
)
ax.set_ylabel("million lines of code", fontsize=14, fontweight="bold")
ax.set_yticks(ax.get_yticks())
ax.set_yticklabels(ax.get_yticklabels(), weight="bold")
ax.set_xlabel("")
ax.set_ylim([0, 53])
ax.set_xticks(ax.get_xticks())
ax.set_xticklabels(ax.get_xticklabels(), weight="bold")
fig.autofmt_xdate()
for i in config["formats"]:
fig.savefig(
f"../lectures/figures/firefox_codebase_growth.{i}",
metadata=config["metadata"][i],
)