Skip to content

Commit 1947798

Browse files
Merge pull request #2325 from plotly/cufflinks
Port cufflinks
2 parents 25da105 + 67bab59 commit 1947798

File tree

3 files changed

+168
-0
lines changed

3 files changed

+168
-0
lines changed

Diff for: binder/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ networkx
1414
scikit-image
1515
datashader
1616
pyarrow
17+
cufflinks==0.17.3

Diff for: doc/python/cufflinks.md

+166
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
---
2+
jupyter:
3+
jupytext:
4+
notebook_metadata_filter: all
5+
text_representation:
6+
extension: .md
7+
format_name: markdown
8+
format_version: "1.2"
9+
jupytext_version: 1.3.1
10+
kernelspec:
11+
display_name: Python 3
12+
language: python
13+
name: python3
14+
language_info:
15+
codemirror_mode:
16+
name: ipython
17+
version: 3
18+
file_extension: .py
19+
mimetype: text/x-python
20+
name: python
21+
nbconvert_exporter: python
22+
pygments_lexer: ipython3
23+
version: 3.6.8
24+
plotly:
25+
description:
26+
Cufflinks is a third-party wrapper library around Plotly, inspired by the Pandas .plot() API.
27+
display_as: file_settings
28+
language: python
29+
layout: base
30+
name: Cufflinks
31+
order: 31
32+
permalink: python/cufflinks/
33+
thumbnail: thumbnail/plotly-express.png
34+
---
35+
36+
### Introduction
37+
38+
[Cufflinks](https://github.com/santosjorge/cufflinks) is a third-party wrapper library around Plotly, maintained by [Santos Jorge](https://github.com/santosjorge).
39+
40+
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.
41+
42+
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.
43+
44+
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).
45+
46+
> Issues and questions regarding Cufflinks should be [raised in the Cufflinks repository](https://github.com/santosjorge/cufflinks/issues/new).
47+
48+
```python
49+
import cufflinks as cf
50+
import pandas as pd
51+
import numpy as np
52+
53+
df = pd.DataFrame(np.random.randn(1000, 2), columns=['A', 'B']).cumsum()
54+
fig = df.iplot(asFigure=True, xTitle="The X Axis",
55+
yTitle="The Y Axis", title="The Figure Title")
56+
fig.show()
57+
```
58+
59+
Cufflinks has a `datagen` module for generating demo data.
60+
61+
```python
62+
import cufflinks as cf
63+
64+
df = cf.datagen.lines()
65+
fig = df.iplot(asFigure=True)
66+
fig.show()
67+
df.head()
68+
```
69+
70+
### Scatter Plots
71+
72+
```python
73+
import cufflinks as cf
74+
import pandas as pd
75+
import numpy as np
76+
77+
df = pd.DataFrame(np.random.randn(1000, 2), columns=['A', 'B']).cumsum()
78+
fig = df.iplot(asFigure=True, x='A', y='B', mode='markers')
79+
fig.show()
80+
```
81+
82+
### Bar Charts
83+
84+
```python
85+
import cufflinks as cf
86+
import pandas as pd
87+
df = pd.DataFrame(np.random.rand(10, 4), columns=['A', 'B', 'C', 'D'])
88+
fig = df.iplot(asFigure=True, kind="bar")
89+
fig.show()
90+
```
91+
92+
### Histograms
93+
94+
```python
95+
import cufflinks as cf
96+
import pandas as pd
97+
df = pd.DataFrame({'a': np.random.randn(1000) + 1,
98+
'b': np.random.randn(1000),
99+
'c': np.random.randn(1000) - 1})
100+
101+
fig = df.iplot(asFigure=True, kind="histogram")
102+
fig.show()
103+
```
104+
105+
### Box Plots
106+
107+
```python
108+
import cufflinks as cf
109+
import pandas as pd
110+
df = pd.DataFrame({'a': np.random.randn(1000) + 1,
111+
'b': np.random.randn(1000),
112+
'c': np.random.randn(1000) - 1})
113+
114+
fig = df.iplot(asFigure=True, kind="box")
115+
fig.show()
116+
```
117+
118+
### Subplots
119+
120+
```python
121+
import cufflinks as cf
122+
123+
df=cf.datagen.lines(4)
124+
fig = df.iplot(asFigure=True, subplots=True, shape=(4,1), shared_xaxes=True, fill=True)
125+
fig.show()
126+
```
127+
128+
```python
129+
import cufflinks as cf
130+
131+
df=cf.datagen.lines(4)
132+
fig = df.iplot(asFigure=True, subplots=True, subplot_titles=True, legend=False)
133+
fig.show()
134+
```
135+
136+
### Line and Box Annotations
137+
138+
```python
139+
import cufflinks as cf
140+
141+
df=cf.datagen.lines(4)
142+
fig = df.iplot(asFigure=True, hline=[2,4], vline=['2015-02-10'])
143+
fig.show()
144+
```
145+
146+
```python
147+
import cufflinks as cf
148+
149+
df=cf.datagen.lines(4)
150+
fig = df.iplot(asFigure=True, hspan=[(-1,1),(2,5)])
151+
fig.show()
152+
```
153+
154+
```python
155+
import cufflinks as cf
156+
157+
df=cf.datagen.lines(4)
158+
fig = df.iplot(asFigure=True,
159+
vspan={'x0':'2015-02-15','x1':'2015-03-15',
160+
'color':'rgba(30,30,30,0.3)','fill':True,'opacity':.4})
161+
fig.show()
162+
```
163+
164+
### More Examples
165+
166+
More documentation and examples for Cufflinks can be found in its [Github repository](https://github.com/santosjorge/cufflinks).

Diff for: doc/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ pathlib
2424
python-frontmatter
2525
datashader
2626
pyarrow
27+
cufflinks==0.17.3

0 commit comments

Comments
 (0)