Part 1: Multiple Plots

Using make_subplots takes the following steps:

  • subplot_titles is used to denote the title of each subplots
  • we can also disable shared xaxes title function by calling shared_xaxes=False ; then use fig.update_xaxesto set individual xaxes titles.

Part 2: Basic Plot Element

Part 2.1: Pie

go.Pie

  • how to make sure that several pies in different HTMLs share the same color scheme
color_dict = {'A': px.colors.qualitative.G10[1], 
'B': px.colors.qualitative.G10[5],
'C': px.colors.qualitative.G10[2],
'D': px.colors.qualitative.G10[0],
'E': px.colors.qualitative.G10[7]}

color_list = np.array([''] * len(tmp_dict['type']), dtype = object)
for index, type in enumerate(tmp_dict['type']):
color_list[index] = color_dict[type]
fig.add_trace(go.Pie(labels=tmp_dict['AB'],
values=tmp_dict['CD'],
pull=[DetectionEnum.indicator(ele) for ele in tmp_dict['type']],
marker={'colors':color_list}
)

Part 3: Plotly Express

Part 3.1 Change the label

Axis titles (and legend titles) can also be overridden using the labels argument of Plotly Express functions:

import plotly.express as px
df = px.data.tips()
fig = px.scatter(df, x="total_bill", y="tip", color="sex",
labels=dict(total_bill="Total Bill ($)", tip="Tip ($)", sex="Payer Gender")
)
fig.show()

Reference