2025.42 changes
This commit is contained in:
27
source/plotting/charts/plotly_figure_pie.py
Normal file
27
source/plotting/charts/plotly_figure_pie.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import pandas as pd
|
||||
from plotly.graph_objs import Figure, Pie
|
||||
from plotly.colors import qualitative
|
||||
|
||||
data = pd.DataFrame(data={
|
||||
"product": ["oignon", "carotte", "pomme", "poire", "radis", "tomate"],
|
||||
"category": ["légume", "légume", "fruit", "fruit", "légume", "fruit"],
|
||||
"origin": ["Espagne", "France", "France", "France", "France", "Espagne"],
|
||||
"price": [1.69, 2.49, 2.99, 1.79, 1.29, 2.99]
|
||||
})
|
||||
figure = Figure(
|
||||
data=[Pie(
|
||||
values=data["price"],
|
||||
labels=data["product"].str.title(),
|
||||
customdata=data[["category", "origin"]],
|
||||
title="Prix",
|
||||
textinfo="label+value",
|
||||
texttemplate="<b>%{label}</b><br>%{value:.2f}€<br><em>%{customdata[0]}</em><br>%{customdata[1]}",
|
||||
insidetextorientation="tangential")
|
||||
],
|
||||
layout={
|
||||
"template": "seaborn",
|
||||
"font": {"family": "Cabin", "size": 20},
|
||||
"title": "Prix au kilo",
|
||||
"piecolorway": qualitative.Prism
|
||||
})
|
||||
figure.show(renderer="browser")
|
||||
Reference in New Issue
Block a user