Hello,
I would like to display two pie charts on the same level (row). I tried to use the following libraries
Blockquote
import plotly.graph_objects as go
from plotly.subplots import make_subplots
But without any successes… I keep receiving errors messages as I try to use the following pattern :
Blockquote
Create subplots: use ‘domain’ type for Pie subplot
fig = make_subplots(rows=1, cols=2, specs=[[{‘type’:‘domain’}, {‘type’:‘domain’}]])
fig.add_trace(go.Pie(labels=labels, values=‘Quantité de films ayant pour genre principal’, name='genre),
1, 1)
fig.add_trace(go.Pie(labels=labels, values=‘Quantité de films ayant pour genre secondaire’, name='genre),
1, 2)
Use hole
to create a donut-like pie chart
fig.update_traces(hole=.4, hoverinfo=“label+percent+name”)
fig.update_layout(
title_text=“Text”,
# Add annotations in the center of the donut pies.
annotations=[dict(text=‘mytext’, x=0.18, y=0.5, font_size=20, showarrow=False),
dict(text=‘mytext2’, x=0.82, y=0.5, font_size=20, showarrow=False)])
fig.show()
Here’s a copy of the dataframe I used and the two consecutive pie charts I managed to get as single plots.