DEV Community

Cover image for Plotly and Cufflinks
MdMusfikurRahmanSifar
MdMusfikurRahmanSifar

Posted on

Plotly and Cufflinks

Plotly is a interactive python library and cufflinks connects plotly with pandas.

First we need to-
pip install plotly
pip install cufflinks
pip install chart_studio

Then we need to do these-

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import chart_studio.plotly as py
import cufflinks as cf
%matplotlib inline
from plotly import __version__
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
init_notebook_mode(connected=True)
cf.go_offline()
Enter fullscreen mode Exit fullscreen mode

Ahh...now if you don't want to know what are they for just go forward or-
Explanation:

  • We will require plotly version greater than 1.9.0, if you don't have it update plotly
  • We need to give comman to use open source library of plotly. from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot N.B. Plotly is a company that offers online and offline facilities. Some are paid. For our usage we are going to use the offline free services. -init_notebook_mode(connected=True) connects javascript with notebook. Plotly is gonna basically use pandas and python to javascript library
  • cf.go_offline() will allow cufflink use offline

In Matplotlib we use .plot(), in plotly we use iplotly()
So, it is i that is the difference in a sense.
Obviously the arguments are not same.

Basically plotly and cufflinks makes different kinds of plots based on data like matplotly but plotly is interactive and has more dimensions to it. Let's see-

But first let's see for the basics which plots we are gonna discuss-

  • scatter
  • bar
  • box
  • spread
  • ratio
  • heatmap
  • surface
  • histogram
  • bubble

Now-
01
05

Scatter:

02
We have some tools in the right top corner of the plot when we hover the mouse on it. The legends are also interactive.
03
That's one of the advantages we get. Plus the interactive part-
04

Bar:

06

Box:

07

Spread:

08
09

Ratio:

10

Heatmap:

11

Surface:

12
We can rotate the plot

Histogram:

13

Bubble:

14

in .iplot() there's tons of arguments use shift+tab to see them. Now play with the interactive powers. Play with it to know it....

Top comments (0)