'How to add a loonie jpeg to multiple Plotly pie charts
I'm looking to add a loonie jpeg into a plotly pie chart that I've already created. Can't really share the data but it'll look something like this, where the amount in each year will add up to 1. There's 4 entries per year.
Year Status Amount
2012 a 0.8
2012 b 0.05
2012 c 0.11
2012 d 0.04
2013 a 0.83
2013 b 0.06
etc
Heres the code I used to make the plotly charts
lst = list(df.groupby('Year'))
# here we want our grid to be 3 x 3
rows = 3
cols = 3
subplot_titles = [l[0] for l in lst]
specs=[[{'type':'pie'}]*cols]*rows
fig = make_subplots(
rows=rows,
cols=cols,
subplot_titles=subplot_titles,
specs=specs,
print_grid=True
)
for i, l in enumerate(lst):
row = i // cols + 1
col = (i % rows) + 1
d = l[1]
fig.add_trace(go.Pie(labels=d["Status"],
values = d["Amount"],
hovertemplate = "%{label}: <br>Value: %{value} ",
showlegend=True,
textposition='inside',
rotation=90),
row=row,
col=col
)
fig.update_layout(height = 1000,
width = 900,
autosize = False,
title="Yield",
title_x=0.5)
fig.show()
The plots works fine and I got my 7 Pie charts all correct just looking to add a loonie jpeg over the plotly pie charts. Any help would be much appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

