Skip to content

Instantly share code, notes, and snippets.

@drewsberry
Last active December 27, 2018 13:54
Show Gist options
  • Save drewsberry/6d9469bb6dabcfbb322822941f01b775 to your computer and use it in GitHub Desktop.
Save drewsberry/6d9469bb6dabcfbb322822941f01b775 to your computer and use it in GitHub Desktop.
Python script for plotting how many codepoints each Unicode version has assigned
from datetime import date
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
data = [
# (version number, date, number of codepoints assigned)
("1.0.0", date(1991, 10, 1), 7161, ( 5 , 0)),
("1.0.1", date(1992, 6, 1), 28359, ( 5 , -8)),
("1.1" , date(1993, 6, 1), 34223, (-6 , 5)),
("2.0" , date(1996, 6, 1), 38950, (-7 , 5)),
("2.1" , date(1998, 5, 1), 38952, (-7 , -15)),
("3.0" , date(1999, 9, 1), 49259, ( 5 , 0)),
("3.1" , date(2001, 3, 1), 94205, (-7 , 5)),
("3.2" , date(2002, 3, 1), 95221, (-7 , -15)),
("4.0" , date(2003, 4, 1), 96447, (-7 , 5)),
("4.1" , date(2005, 3, 1), 97720, (-7 , -15)),
("5.0" , date(2006, 6, 1), 99089, (-7 , 5)),
("5.1" , date(2008, 4, 1), 100713, (-7 , -15)),
("5.2" , date(2009, 10, 1), 107361, (-9 , 5)),
("6.0" , date(2010, 10, 1), 109449, (-7 , -15)),
("6.1" , date(2012, 1, 1), 110181, (-9 , 5)),
("6.2" , date(2012, 9, 1), 110182, (-7 , -15)),
("6.3" , date(2013, 9, 1), 110187, (-9 , 5)),
("7.0" , date(2014, 6, 1), 113021, ( 5 , -6)),
("8.0" , date(2015, 6, 1), 120737, (-15, 5)),
("9.0" , date(2016, 6, 1), 128237, ( 5 , -7)),
("10.0" , date(2017, 6, 1), 136755, (-16, 5)),
("11.0" , date(2018, 6, 1), 137439, (-7 , -12)),
]
versions = np.array([datum[0] for datum in data])
release_dates = np.array([datum[1] for datum in data])
num_assigned_codepoints = np.array([datum[2] for datum in data])
label_offsets = [datum[3] for datum in data]
fig, ax = plt.subplots()
plt.title("Unicode through the ages")
plt.xlabel("Release date")
plt.ylabel("Number of assigned codepoints")
plt.xlim(date(1990, 1, 1), date(2020, 1, 1))
plt.ylim(0, 150000)
ax.get_yaxis().set_major_formatter(
matplotlib.ticker.FuncFormatter(lambda x, _: format(int(x), ",")))
ax.plot(release_dates, num_assigned_codepoints,
color="blue",
linestyle="--",
linewidth=2.0)
ax.plot(release_dates, num_assigned_codepoints,
color="red",
marker="o",
linewidth=0,
fillstyle="full",
markeredgewidth=0.01)
for i, txt in enumerate(versions):
ax.annotate(txt, (release_dates[i], num_assigned_codepoints[i]),
xytext=label_offsets[i],
textcoords="offset points")
plt.savefig("unicode-history.svg", bbox_inches="tight")
plt.savefig("unicode-history.png", bbox_inches="tight")
@drewsberry
Copy link
Author

Output: plot: Unicode through the ages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment