From 4fa656dd3fe0e42b252f32e5c825da7310974e3a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 9 Dec 2025 23:28:05 +0000 Subject: [PATCH] feat(plotly): implement donut-labeled --- plots/donut-labeled/implementations/plotly.py | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 plots/donut-labeled/implementations/plotly.py diff --git a/plots/donut-labeled/implementations/plotly.py b/plots/donut-labeled/implementations/plotly.py new file mode 100644 index 0000000000..18a66e767f --- /dev/null +++ b/plots/donut-labeled/implementations/plotly.py @@ -0,0 +1,44 @@ +""" +donut-labeled: Donut Chart with Percentage Labels +Library: plotly +""" + +import plotly.graph_objects as go + + +# Data - Budget allocation by department +categories = ["Engineering", "Marketing", "Sales", "Operations", "R&D", "HR"] +values = [35, 20, 18, 12, 10, 5] + +# Color palette from style guide +colors = ["#306998", "#FFD43B", "#DC2626", "#059669", "#8B5CF6", "#F97316"] + +# Create donut chart +fig = go.Figure( + data=[ + go.Pie( + labels=categories, + values=values, + hole=0.55, + marker={"colors": colors, "line": {"color": "white", "width": 2}}, + textinfo="percent", + textfont={"size": 20, "color": "white"}, + textposition="inside", + hovertemplate="%{label}
Value: %{value}
Percentage: %{percent}", + ) + ] +) + +# Layout +fig.update_layout( + title={"text": "Department Budget Allocation", "font": {"size": 28}, "x": 0.5, "xanchor": "center"}, + legend={"orientation": "h", "yanchor": "bottom", "y": -0.15, "xanchor": "center", "x": 0.5, "font": {"size": 18}}, + template="plotly_white", + margin={"t": 80, "b": 80, "l": 40, "r": 40}, +) + +# Save as PNG (4800 x 2700 px) +fig.write_image("plot.png", width=1600, height=900, scale=3) + +# Save as HTML for interactivity +fig.write_html("plot.html", include_plotlyjs="cdn")