Repository navigation
Expand file tree
/
Copy pathindividual-size-graph.py
More file actions
97 lines (79 loc) · 2.67 KB
/
Copy pathindividual-size-graph.py
File metadata and controls
97 lines (79 loc) · 2.67 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# This file is part of the uutils coreutils package.
#
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
import sys
from pathlib import Path
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from graph_common import COLORS, add_title, apply_smoothing, setup_theme, style_axes
df = pd.read_json(sys.argv[1], orient="index")
df.index = pd.to_datetime(df.index, utc=True)
Path("individual-size-results").mkdir(exist_ok=True)
# Set up modern theme
setup_theme()
# Use color from common module
size_color = COLORS["default"]
for name, series in df["sizes"].apply(pd.Series).items():
# Filter out None values which indicate missing data for 'name'
sizes = series.dropna()
if not sizes.empty:
print(name)
print(sizes)
# Create figure with better proportions and higher DPI
fig, ax = plt.subplots(figsize=(18, 9), dpi=100)
# Prepare data for Seaborn
plot_data = pd.DataFrame(
{"date": sizes.index, "size": pd.to_numeric(sizes.values, errors="coerce")}
)
# Apply smoothing using rolling average
plot_data["size_smooth"] = apply_smoothing(plot_data, None, "size")
# Add gradient-like area fill first
ax.fill_between(
plot_data["date"],
0,
plot_data["size"],
alpha=0.2,
color=size_color,
zorder=1,
linewidth=0,
)
# Use Seaborn's lineplot with enhanced styling and smoothed data
sns.lineplot(
data=plot_data,
x="date",
y="size_smooth",
color=size_color,
linewidth=4,
ax=ax,
marker=False, # Disable markers for smoother look
alpha=1,
zorder=3,
)
# Add title and subtitle
add_title(
ax,
f'uutils coreutils — "{name}" Binary Size',
"Individual utility size tracking over development history",
)
# Style axes with labels and grid
style_axes(ax, xlabel="Date", ylabel="Size (kilobytes)")
# Tight layout
plt.tight_layout()
# Save with high quality
plt.savefig(
f"individual-size-results/{name}.svg",
format="svg",
dpi=300,
bbox_inches="tight",
facecolor="white",
edgecolor="none",
metadata={
"Creator": "uutils coreutils tracking",
"Title": f"{name} Binary Size",
},
)
plt.close(fig)
else:
print(f"Warning: No data found for '{name}'")