In [1]:
import plotly.express as px
import seaborn as sns
In [2]:
df_tip = sns.load_dataset('tips')
df_tip.head()
Out[2]:
total_bill tip sex smoker day time size
0 16.99 1.01 Female No Sun Dinner 2
1 10.34 1.66 Male No Sun Dinner 3
2 21.01 3.50 Male No Sun Dinner 3
3 23.68 3.31 Male No Sun Dinner 2
4 24.59 3.61 Female No Sun Dinner 4
In [3]:
# fig = make_subplots(1, 2, specs=[[{'type': 'domain'}, {'type': 'domain'}]])

# fig.add_trace(
#     go.Pie(
#         labels=df_tip['sex'],
#         values=df_tip['tip'],
#         text=df_tip['sex'],
#     ), 1, 1
# )

# fig.add_trace(
#     go.Pie(
#         labels=df_tip['time'],
#         values=df_tip['tip'],
#         text=df_tip['time'],
#     ), 1, 2
# )

# fig.update_layout(title_text='Plotly Pie Charts using graph_ojbects and subplots')
# fig.show()
In [4]:
fig = px.pie(df_tip, values='tip',  names='sex', title='Using plot.ly express')
fig.show()