From 58fef6612ee3b0c396ab050508341ad0ec2e05c0 Mon Sep 17 00:00:00 2001 From: yuji96 Date: Wed, 5 Apr 2023 11:28:26 +0900 Subject: [PATCH] align center annotations in donut pies --- doc/python/pie-charts.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/python/pie-charts.md b/doc/python/pie-charts.md index 8564822091e..2d0a6db1f19 100644 --- a/doc/python/pie-charts.md +++ b/doc/python/pie-charts.md @@ -235,8 +235,10 @@ fig.update_traces(hole=.4, hoverinfo="label+percent+name") fig.update_layout( title_text="Global Emissions 1990-2011", # Add annotations in the center of the donut pies. - annotations=[dict(text='GHG', x=0.18, y=0.5, font_size=20, showarrow=False), - dict(text='CO2', x=0.82, y=0.5, font_size=20, showarrow=False)]) + annotations=[dict(text='GHG', x=sum(fig.get_subplot(1, 1).x) / 2, y=0.5, + font_size=20, showarrow=False, xanchor="center"), + dict(text='CO2', x=sum(fig.get_subplot(1, 2).x) / 2, y=0.5, + font_size=20, showarrow=False, xanchor="center")]) fig.show() ```