-
-
Save MarcoGorelli/eb36268edb1b64b1f182fa606cc54cd1 to your computer and use it in GitHub Desktop.
nested pie charts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import matplotlib.pyplot as plt | |
| from matplotlib.cm import get_cmap | |
| import numpy as np | |
| fig, ax = plt.subplots() | |
| timings = np.array([11, 360, 573, 758]) | |
| total_timings = np.vstack([timings, 1000 - timings]) | |
| inner = total_timings[:, 0] | |
| mid = total_timings[:, 1] | |
| mid1 = total_timings[:, 2] | |
| outer = total_timings[:, 3] | |
| labels_inner = ["polars (11 sec)", ""] | |
| labels_mid = ["pandas (360 sec)", ""] | |
| labels_mid1 = ["dask (573 sec)", ""] | |
| labels_outer = ["modin (758 sec)", ""] | |
| ax.pie( | |
| inner, | |
| radius=0.4, | |
| wedgeprops=dict(width=0.2, edgecolor="w"), | |
| labels=labels_inner, | |
| counterclock=False, | |
| startangle=90, | |
| colors=[(1, 0, 0, 1), (0, 0, 0, 0)], | |
| labeldistance=None, | |
| ) | |
| ax.pie( | |
| mid, | |
| radius=0.6, | |
| wedgeprops=dict(width=0.2, edgecolor="w"), | |
| labels=labels_mid, | |
| counterclock=False, | |
| startangle=90, | |
| colors=[(0.3, 0.6, 0, 1), (0, 0, 0, 0)], | |
| labeldistance=None, | |
| ) | |
| ax.pie( | |
| mid1, | |
| radius=0.8, | |
| wedgeprops=dict(width=0.2, edgecolor="w"), | |
| labels=labels_mid1, | |
| counterclock=False, | |
| startangle=90, | |
| colors=[(0, 0.3, 0.3, 1), (0, 0, 0, 0)], | |
| labeldistance=None, | |
| ) | |
| ax.pie( | |
| outer, | |
| radius=1, | |
| wedgeprops=dict(width=0.2, edgecolor="w"), | |
| labels=labels_outer, | |
| counterclock=False, | |
| startangle=90, | |
| colors=[(0, 0, 0.6, 1), (0, 0, 0, 0)], | |
| labeldistance=None, | |
| ) | |
| ax.set(aspect="equal", title="Duration in seconds") | |
| plt.legend(loc=(-0.3, 0)) | |
| fig.savefig("fig.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment