1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| total17 = ( df17['region'] .value_counts() .to_frame() .reset_index() .rename(columns={'index':'type', 'region':'respodents'}) .groupby('type') .sum() .reset_index() ) total18 = ( df18['region'] .value_counts() .to_frame() .reset_index() .rename(columns={'index':'type', 'region':'respodents'}) .groupby('type') .sum() .reset_index() ) total19 = ( df19['region'] .value_counts() .to_frame() .reset_index() .rename(columns={'index':'type', 'region':'respodents'}) .groupby('type') .sum() .reset_index() ) total20 = ( df20['region'] .value_counts() .to_frame() .reset_index() .rename(columns={'index':'type', 'region':'respodents'}) .groupby('type') .sum() .reset_index() ) total21 = ( df21['region'] .value_counts() .to_frame() .reset_index() .rename(columns={'index':'type', 'region':'respodents'}) .groupby('type') .sum() .reset_index() )
colors = ['#88BFBA','#F28705']
fig = make_subplots(rows=1, cols=5, specs=[[{'type':'domain'}, {'type':'domain'}, {'type':'domain'}, {'type':'domain'}, {'type':'domain'}]], subplot_titles=("2017", "2018", "2019", "2020", "2021")) fig.add_trace(go.Pie(marker=dict(colors=colors),labels=total21['type'], values=total21['respodents'], name="2021", scalegroup='one'), 1, 1) fig.add_trace(go.Pie(marker=dict(colors=colors),labels=total20['type'], values=total20['respodents'], name="2020", scalegroup='one'), 1, 2) fig.add_trace(go.Pie(marker=dict(colors=colors),labels=total19['type'], values=total19['respodents'], name="2019", scalegroup='one'), 1, 3) fig.add_trace(go.Pie(marker=dict(colors=colors),labels=total18['type'], values=total18['respodents'], name="2018", scalegroup='one'), 1, 4) fig.add_trace(go.Pie(marker=dict(colors=colors),labels=total17['type'], values=total17['respodents'], name="2017", scalegroup='one'), 1, 5)
fig.update_traces(hole=.0, hoverinfo="label+percent+name", textfont_size=15,)
fig.update_layout(showlegend=False, margin=dict(pad=20), height=100, yaxis_title=None, xaxis_title=None, title_text="<b>World vs EastAsia</b>", title_font_size=22, font=dict(size=17, color='#000000'), autosize=True)
fig.update_xaxes(showgrid=False) fig.update_yaxes(showgrid=False)
fig.show()
|