From 44f61a8fe59439744fd6baa508545de1b6a85490 Mon Sep 17 00:00:00 2001 From: Nicolas Kruchten Date: Fri, 27 Mar 2020 11:08:09 -0400 Subject: [PATCH 1/5] Port cufflinks --- doc/python/cufflinks.md | 166 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 doc/python/cufflinks.md diff --git a/doc/python/cufflinks.md b/doc/python/cufflinks.md new file mode 100644 index 00000000000..d0c582aba5c --- /dev/null +++ b/doc/python/cufflinks.md @@ -0,0 +1,166 @@ +--- +jupyter: + jupytext: + notebook_metadata_filter: all + text_representation: + extension: .md + format_name: markdown + format_version: "1.2" + jupytext_version: 1.3.1 + kernelspec: + display_name: Python 3 + language: python + name: python3 + language_info: + codemirror_mode: + name: ipython + version: 3 + file_extension: .py + mimetype: text/x-python + name: python + nbconvert_exporter: python + pygments_lexer: ipython3 + version: 3.6.8 + plotly: + description: + Cufflinks is a third-party wrapper library around Plotly, inspired by the Pandas .plot() API. + display_as: file_settings + language: python + layout: base + name: Cufflinks + order: 31 + page_type: example_index + permalink: python/cufflinks/ + thumbnail: thumbnail/plotly-express.png +--- + +### Introduction + +[Cufflinks](https://github.com/santosjorge/cufflinks) is a third-party wrapper library around Plotly, maintained by [Santos Jorge](https://github.com/santosjorge). + +When you import cufflinks, all [Pandas](https://pandas.pydata.org/) 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](/python/plotly-express/), by returning [customizable `go.Figure` objects](/python/styling-plotly-express/) which are compatible with [Dash](https://dash.plot.ly)'s [`dcc.Graph` component](https://dash.plotly.com/dash-core-components/graph). 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](https://github.com/santosjorge/cufflinks). + +> Issues and questions regarding Cufflinks should be [raised in the Cufflinks repository](https://github.com/santosjorge/cufflinks/issues/new). + +```python +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. + +```python +import cufflinks as cf + +df = cf.datagen.lines() +fig = df.iplot(asFigure=True) +fig.show() +df.head() +``` + +### Scatter Plots + +```python +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 + +```python +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 + +```python +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 + +```python +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 + +```python +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() +``` + +```python +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 + +```python +import cufflinks as cf + +df=cf.datagen.lines(4) +fig = df.iplot(asFigure=True, hline=[2,4],vline=['2015-02-10']) +fig.show() +``` + +```python +import cufflinks as cf + +df=cf.datagen.lines(4) +fig = df.iplot(asFigure=True, hspan=[(-1,1),(2,5)]) +fig.show() +``` + +```python +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](https://github.com/santosjorge/cufflinks). From e7b31d5328e50f3a5a6fff8908437e75ccca6ce4 Mon Sep 17 00:00:00 2001 From: Nicolas Kruchten Date: Fri, 27 Mar 2020 11:13:00 -0400 Subject: [PATCH 2/5] requirements --- binder/requirements.txt | 1 + doc/requirements.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/binder/requirements.txt b/binder/requirements.txt index 46cdd67d0f0..7322ecb9308 100644 --- a/binder/requirements.txt +++ b/binder/requirements.txt @@ -14,3 +14,4 @@ networkx scikit-image datashader pyarrow +cufflinks==0.17.3 diff --git a/doc/requirements.txt b/doc/requirements.txt index 868b71ee72d..0df715ec0a0 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -24,3 +24,4 @@ pathlib python-frontmatter datashader pyarrow +cufflinks==0.17.3 From 1995e2d019b7bdd46682882ab5e6c9aaa5db1ca3 Mon Sep 17 00:00:00 2001 From: Nicolas Kruchten Date: Fri, 27 Mar 2020 11:36:07 -0400 Subject: [PATCH 3/5] fix ci check --- doc/python/cufflinks.md | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/python/cufflinks.md b/doc/python/cufflinks.md index d0c582aba5c..f9cd5ca41cc 100644 --- a/doc/python/cufflinks.md +++ b/doc/python/cufflinks.md @@ -29,7 +29,6 @@ jupyter: layout: base name: Cufflinks order: 31 - page_type: example_index permalink: python/cufflinks/ thumbnail: thumbnail/plotly-express.png --- From 031f6cdf8c8c3736e3d23274838cc64c6f7a440d Mon Sep 17 00:00:00 2001 From: Nicolas Kruchten Date: Fri, 27 Mar 2020 12:14:45 -0400 Subject: [PATCH 4/5] Update doc/python/cufflinks.md Co-Authored-By: Emmanuelle Gouillart --- doc/python/cufflinks.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/cufflinks.md b/doc/python/cufflinks.md index f9cd5ca41cc..10d5348cf97 100644 --- a/doc/python/cufflinks.md +++ b/doc/python/cufflinks.md @@ -138,7 +138,7 @@ fig.show() import cufflinks as cf df=cf.datagen.lines(4) -fig = df.iplot(asFigure=True, hline=[2,4],vline=['2015-02-10']) +fig = df.iplot(asFigure=True, hline=[2,4], vline=['2015-02-10']) fig.show() ``` From 67bab5922223a9077f042349c09dec5511737619 Mon Sep 17 00:00:00 2001 From: Nicolas Kruchten Date: Fri, 27 Mar 2020 12:14:51 -0400 Subject: [PATCH 5/5] Update doc/python/cufflinks.md Co-Authored-By: Emmanuelle Gouillart --- doc/python/cufflinks.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/python/cufflinks.md b/doc/python/cufflinks.md index 10d5348cf97..5683bfcd422 100644 --- a/doc/python/cufflinks.md +++ b/doc/python/cufflinks.md @@ -51,7 +51,8 @@ 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 = df.iplot(asFigure=True, xTitle="The X Axis", + yTitle="The Y Axis", title="The Figure Title") fig.show() ```