My Plotly Note

Part 1: Multiple Plots

Using make_subplots takes the following steps:

(1) generate a figure via make_subplots function

(2) add trace via add_trace function

(3) update_layout is used to reset the image setting

Notes on make_subplots

  • specs is an important parameter in make_subplots , and it will determine the type of plots we want to have, for example, if we want to have pie plot, then we should write specs=[[{'type':'pie'}]]
  • 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


  • pull is used to emphasize some parts of the pie plot see this example
  • 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]
pull=[DetectionEnum.indicator(ele) for ele in tmp_dict['type']],

see color sequence in plotly express to check the default color maps provided by plotly

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 as px
df =
fig = px.scatter(df, x="total_bill", y="tip", color="sex",
labels=dict(total_bill="Total Bill ($)", tip="Tip ($)", sex="Payer Gender")






Love podcasts or audiobooks? Learn on the go with our new app.

Ansible Tutorial — Learn How To Write Playbooks With Hands-On

Being a startup CTO in Stuttgart playing Tic Tac Toe at work

Building a scraper Slack bot using Amazon EventBridge

Rust Programming: Why print! is used instead of print?

MultiMillion x Im Community AMA Recap

All You Need To Know About AWS Data Analytics Exam And Its Preparation

Deploy a Swarm Cluster with Alexa

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


More from Medium

2022 Python Data Analysis & Visualization Masterclass

2022 Python Data Analysis & Visualization Masterclass

World Food Production Descriptive Analysis in Python

Exploratory Data Analysis of Black Friday Sales using Plotly — Python

Python Data Science Toolbox (Part 2): Bringing it all together!