Skip to content

Commit 7881c29

Browse files
committed
Merge branch 'loops' into custom-font
2 parents 6a080d5 + a00a0aa commit 7881c29

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

scripts/fonts.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@
2222
}
2323

2424
text = "The quick brown fox jumps over the lazy dog"
25-
for i, variant in enumerate(variants.keys()):
26-
ax.text(1, y, text, size=9, va="center",
27-
font=Path(variants[variant]).resolve())
25+
for i, (variant, file) in enumerate(variants.items()):
26+
ax.text(1, y, text, size=9, va="center", font=Path(file).resolve())
2827

2928
ax.text(39, y, variant,
3029
color="0.25", va="center", ha="right",
@@ -55,12 +54,11 @@
5554
"Source Code Pro" : "monospace" }
5655

5756
text = "The quick brown fox jumps over the lazy dog"
58-
for i, family in enumerate(families):
57+
for i, (family, label) in enumerate(families.items()):
5958
ax.text(1, y, text,
6059
va="center", size=9, family=family, weight="regular")
6160

62-
ax.text(39, y,
63-
"%s" % (families[family]),
61+
ax.text(39, y, label,
6462
color="0.25", va="center", ha="right",
6563
size="small", family="Source Code Pro", weight=400)
6664
y += 1.65
@@ -83,7 +81,7 @@
8381
ax.text(1, y, text, size=9,
8482
va="center", family="Source Sans Pro", weight=weight)
8583

86-
ax.text(39, y, "%s (%d)" % (weight, weights[weight]),
84+
ax.text(39, y, f"{weight} ({weights[weight]:d})",
8785
color="0.25", va="center", ha="right",
8886
size="small", family="Source Code Pro", weight=400)
8987
y += 1.65
@@ -99,11 +97,11 @@
9997
"xx-large" : 1.728 }
10098

10199
text = "The quick brown fox"
102-
for i, size in enumerate(sizes.keys()):
100+
for i, (size, scaling) in enumerate(sizes.items()):
103101
ax.text(1, y, text, size=size,
104102
ha="left", va="center", family="Source Sans Pro", weight="light")
105103

106-
ax.text(39, y, "%s (%.2f)" % (size, sizes[size]),
104+
ax.text(39, y, f"{size} ({scaling:.2f})",
107105
color="0.25", va="center", ha="right",
108106
size="small", family="Source Code Pro", weight=400)
109107
y += 1.65* max(sizes[size], sizes["small"])

scripts/tip-hatched.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
x2, y2 = x1+1, np.random.randint(25, 75, 2)
2121

2222
ax.bar(x1, y1, color=color2)
23-
for i in range(len(x1)):
24-
plt.annotate("%d%%" % y1[i], (x1[i], y1[i]), xytext=(0, 1),
23+
for x, y in zip(x1, y1):
24+
plt.annotate(f"{y:d}%", (x, y), xytext=(0, 1),
2525
fontsize="x-small", color=color2,
2626
textcoords="offset points", va="bottom", ha="center")
2727

2828
ax.bar(x2, y2, color=color2, hatch="/" )
29-
for i in range(len(x2)):
30-
plt.annotate("%d%%" % y2[i], (x2[i], y2[i]), xytext=(0, 1),
29+
for x, y in zip(x2, y2):
30+
plt.annotate(f"{y:d}%", (x, y), xytext=(0, 1),
3131
fontsize="x-small", color=color2,
3232
textcoords="offset points", va="bottom", ha="center")
3333

0 commit comments

Comments
 (0)