Skip to content

Latest commit

 

History

History
166 lines (130 loc) · 4.38 KB

cufflinks.md

File metadata and controls

166 lines (130 loc) · 4.38 KB
jupyter
jupytext kernelspec language_info plotly
notebook_metadata_filter text_representation
all
extension format_name format_version jupytext_version
.md
markdown
1.2
1.3.1
display_name language name
Python 3
python
python3
codemirror_mode file_extension mimetype name nbconvert_exporter pygments_lexer version
name version
ipython
3
.py
text/x-python
python
python
ipython3
3.6.8
description display_as language layout name order permalink thumbnail
Cufflinks is a third-party wrapper library around Plotly, inspired by the Pandas .plot() API.
file_settings
python
base
Cufflinks
31
python/cufflinks/
thumbnail/plotly-express.png

Introduction

Cufflinks is a third-party wrapper library around Plotly, maintained by Santos Jorge.

When you import cufflinks, all Pandas data frames and series objects have a new method attached to them called .iplot() which has a similar API to Pandas' built-in .plot() method.

By passing the asFigure=True argument to .iplot(), Cufflinks works similarly to Plotly Express, by returning customizable go.Figure objects which are compatible with Dash's dcc.Graph component. Cufflinks also adds a .figure() method which has the same signature as .iplot() except that it has asFigure=True set as the default.

This page shows some high-level examples of how to use Cufflinks, and more examples and documentation are available in the Cufflinks Github repository.

Issues and questions regarding Cufflinks should be raised in the Cufflinks repository.

import cufflinks as cf
import pandas as pd
import numpy as np

df = pd.DataFrame(np.random.randn(1000, 2), columns=['A', 'B']).cumsum()
fig = df.iplot(asFigure=True, xTitle="The X Axis",
                    yTitle="The Y Axis", title="The Figure Title")
fig.show()

Cufflinks has a datagen module for generating demo data.

import cufflinks as cf

df = cf.datagen.lines()
fig = df.iplot(asFigure=True)
fig.show()
df.head()

Scatter Plots

import cufflinks as cf
import pandas as pd
import numpy as np

df = pd.DataFrame(np.random.randn(1000, 2), columns=['A', 'B']).cumsum()
fig = df.iplot(asFigure=True, x='A', y='B', mode='markers')
fig.show()

Bar Charts

import cufflinks as cf
import pandas as pd
df = pd.DataFrame(np.random.rand(10, 4), columns=['A', 'B', 'C', 'D'])
fig = df.iplot(asFigure=True, kind="bar")
fig.show()

Histograms

import cufflinks as cf
import pandas as pd
df = pd.DataFrame({'a': np.random.randn(1000) + 1,
                   'b': np.random.randn(1000),
                   'c': np.random.randn(1000) - 1})

fig = df.iplot(asFigure=True, kind="histogram")
fig.show()

Box Plots

import cufflinks as cf
import pandas as pd
df = pd.DataFrame({'a': np.random.randn(1000) + 1,
                   'b': np.random.randn(1000),
                   'c': np.random.randn(1000) - 1})

fig = df.iplot(asFigure=True, kind="box")
fig.show()

Subplots

import cufflinks as cf

df=cf.datagen.lines(4)
fig = df.iplot(asFigure=True, subplots=True, shape=(4,1), shared_xaxes=True, fill=True)
fig.show()
import cufflinks as cf

df=cf.datagen.lines(4)
fig = df.iplot(asFigure=True, subplots=True, subplot_titles=True, legend=False)
fig.show()

Line and Box Annotations

import cufflinks as cf

df=cf.datagen.lines(4)
fig = df.iplot(asFigure=True, hline=[2,4], vline=['2015-02-10'])
fig.show()
import cufflinks as cf

df=cf.datagen.lines(4)
fig = df.iplot(asFigure=True, hspan=[(-1,1),(2,5)])
fig.show()
import cufflinks as cf

df=cf.datagen.lines(4)
fig = df.iplot(asFigure=True,
               vspan={'x0':'2015-02-15','x1':'2015-03-15',
                      'color':'rgba(30,30,30,0.3)','fill':True,'opacity':.4})
fig.show()

More Examples

More documentation and examples for Cufflinks can be found in its Github repository.