Add source example files

This commit is contained in:
2025-07-12 18:43:56 +02:00
parent 11d6846f49
commit d0bcfcf8f1
62 changed files with 40101 additions and 161 deletions

View File

@ -0,0 +1,24 @@
"""
Display sales of various cities in a sunburst chart.
Given the cities can have recurring parents, we can have
a sunburst chart with 2 rings, the centermost ring for the
country, and the outmost ring to have sales per city.
"""
import matplotlib
import pandas as pd
from matplotlib import pyplot
if __name__ == '__main__':
matplotlib.use("QtCairo")
df = pd.DataFrame(data={
"country": ["France", "France", "Spain", "Spain"],
"city": ["Montpellier", "Bordeaux", "Madrid", "Valencia"],
"sales": [150_000, 127_000, 97_200, 137_250]
})
df.set_index(["country", "city"], inplace=True)
total: int = df["sales"].sum()
print(df)
axes = df.plot.pie(subplots=True, autopct=lambda x: f"{x * total / 100:.0f} {x:.2f}%")
pyplot.show()