Learn practical skills, build real-world projects, and advance your career

Plotly: an incredible Python library to plot interactive graphs

Introduction

Why do we need graphs?

Graphs are visual representation of data. Just by looking at the graphs, we are able to understand the patterns in the data, which are very difficult to understand with tabular or textual representation. Graphs display information in a manner that is very easy for most people to understand. In data analytics, graphs are used to understand the relationship between variables/columns to gain insights about the data.
Graphs come in very different forms with equally different uses. The type of graphs is dependent on the type of data that is being conveyed.

Plotly is a free open source library for plotting graphs. It is used to create data visualisation that can be displayed in jupyter notebooks. It provides with variety of graphing options, right from line chart to 3-D charts. It also works offline.

To install plotly, run the following command in your terminal or inside the code cell of your jupyter notebook

pip install plotly

We will also need another python library, pandas, to read the example datasets into the jupyter notebooks. To install pandas, run the following command

pip install pandas

Enough theory, let's jump into coding!!

Imports

!pip install plotly
Collecting plotly Downloading plotly-5.2.1-py2.py3-none-any.whl (21.8 MB) |████████████████████████████████| 21.8 MB 6.0 MB/s eta 0:00:01 |██████████████▍ | 9.8 MB 6.0 MB/s eta 0:00:02 |████████████████▋ | 11.3 MB 6.0 MB/s eta 0:00:020:02�███████████████████████▎ | 16.5 MB 6.0 MB/s eta 0:00:01 Requirement already satisfied: six in /opt/conda/lib/python3.9/site-packages (from plotly) (1.16.0) Collecting tenacity>=6.2.0 Downloading tenacity-8.0.1-py3-none-any.whl (24 kB) Installing collected packages: tenacity, plotly Successfully installed plotly-5.2.1 tenacity-8.0.1