pct graph: Sort areas by Python version.

This commit is contained in:
Julien Palard 2022-01-27 23:52:35 +01:00
parent eca30e66d9
commit 3b04f6b39b
Signed by: mdk
GPG Key ID: 0EFC1AC1006886F8
2 changed files with 15 additions and 1 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 64 KiB

View File

@ -140,7 +140,20 @@ def plot_main():
plt.savefig("python-versions.png")
HIDE = {"1.17", "2.4", "2.5", "2.6", "3.2", "3.3", "3.4"}
def plot_pct():
def by_version(version_string):
try:
minor, major = version_string.split(".")
return float(minor), float(major)
except ValueError:
return 0, 0
def by_versions(version_strings):
return version_strings.map(by_version)
db = DB()
versions = pd.DataFrame(
db.fetch_python_version(),
@ -157,8 +170,9 @@ def plot_pct():
versions["date"] = pd.to_datetime(versions.start_date) + timedelta(days=14)
versions.set_index(["python_version", "date"], inplace=True)
to_plot = versions.pct.unstack(0, fill_value=0)
to_plot.sort_values(by="python_version", axis=1, inplace=True, key=by_versions)
for version in to_plot:
if to_plot[version].sum() < to_plot.sum().sum() / 75:
if version in HIDE:
to_plot["Other"] += to_plot[version]
del to_plot[version]
plt.style.use("tableau-colorblind10")