Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds documentation and violin plots! #107

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .nojekyll
Empty file.
21,315 changes: 21,154 additions & 161 deletions Cufflinks Tutorial - Chart Gallery.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cufflinks/datagen.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def histogram(n_traces=1,n=500,mode=None):
'abc' for alphabet columns
'stocks' for random stock names
"""
df=pd.DataFrame(np.random.randn(n,n_traces)+np.random.randint(-1,2),
df=pd.DataFrame(np.random.randn(n,n_traces)+np.random.randint(-2,2, n_traces),
columns=getName(n_traces,mode=mode))
return df

Expand Down
20 changes: 18 additions & 2 deletions cufflinks/plotlytools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import copy
# from plotly.graph_objs import *
import plotly.graph_objs as go
import plotly.figure_factory as ff
from collections import defaultdict
from IPython.display import display,Image
from .exceptions import CufflinksError
Expand Down Expand Up @@ -672,6 +673,7 @@ def _iplot(self,kind='scatter',data=None,layout=None,filename='',sharing=None,ti
# Valid Kwargs
valid_kwargs = ['color','opacity','column','columns','labels','text','world_readable','colorbar']
TRACE_KWARGS = ['hoverinfo','connectgaps']
VIOLIN_KWARGS = ['rugplot']
HEATMAP_SURFACE_KWARGS = ['center_scale','zmin','zmax']
PIE_KWARGS=['sort','pull','hole','textposition','textinfo','linecolor','linewidth','textcolor']
OHLC_KWARGS=['up_color','down_color','open','high','low','close','volume','name','decreasing','increasing']
Expand All @@ -682,7 +684,7 @@ def _iplot(self,kind='scatter',data=None,layout=None,filename='',sharing=None,ti
'error_width','error_opacity']
EXPORT_KWARGS=['display_image','scale']
kwargs_list = [tools.__LAYOUT_KWARGS,TRACE_KWARGS,
OHLC_KWARGS,PIE_KWARGS,HEATMAP_SURFACE_KWARGS,SUBPLOT_KWARGS,GEO_KWARGS,ERROR_KWARGS,EXPORT_KWARGS]
OHLC_KWARGS,VIOLIN_KWARGS,PIE_KWARGS,HEATMAP_SURFACE_KWARGS,SUBPLOT_KWARGS,GEO_KWARGS,ERROR_KWARGS,EXPORT_KWARGS]
[valid_kwargs.extend(_) for _ in kwargs_list]

dict_modifiers_keys = ['line']
Expand Down Expand Up @@ -868,7 +870,7 @@ def get_marker(marker={}):
line=go.Line(width=width))
trace=go.Scatter(x=x,y=y,marker=marker,mode='markers',text=labels)
data=go.Data([trace])
elif kind in ('box','histogram','hist'):
elif kind in ('box','histogram','hist','violin'):
if isinstance(self,pd.core.series.Series):
df=pd.DataFrame({self.name:self})
else:
Expand All @@ -883,6 +885,20 @@ def get_marker(marker={}):
if kind=='box':
__=go.Box(y=df[_].values.tolist(),marker=go.Marker(color=clrs[_]),name=_,
line=go.Line(width=width),boxpoints=boxpoints)
elif kind=='violin':
dimensions = dimensions if dimensions else (None, None)
kw = check_kwargs(kwargs,VIOLIN_KWARGS)
rugplot = kw.pop('rugplot', True)
figure = ff.create_violin(df.melt(), data_header='value', group_header='variable',
title=title, colors=colors, rugplot=rugplot,
width = dimensions[0], height=dimensions[1])
if asFigure:
return figure
else:
return iplot(figure,validate=validate,sharing=sharing,filename=filename,
online=online,asImage=asImage,asUrl=asUrl,asPlot=asPlot,
dimensions=dimensions,display_image=kwargs.get('display_image',True))

else:
__=go.Histogram(x=df[_].values.tolist(),name=_,
marker=go.Marker(color=clrs[_], line=go.Line(width=width)),
Expand Down
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
doctrees
Empty file added docs/.nojekyll
Empty file.
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = Cufflinks
SOURCEDIR = source
BUILDDIR = .

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
33 changes: 33 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Cufflinks Documentation

Generated using Sphinx.

### Creating Documentation Scaffold

We first create the configuration as outlined [here](https://gisellezeno.com/tutorials/sphinx-for-python-documentation.html).
We create a docs folder and using the configuration in this tutorial we run:

```
sphinx-quickstart
```

We then have to setup the conf.py file in /source as detailed in the above link.

We create the .rst files which outline how the documentation is to be compiled.
From the docs folder, we run:

```
sphinx-apidoc -f --separate -o source/ ../cufflinks/
```

### Generation of Documentation

To generate the documentation from the .rst templates, run the following from /docs:

```
make html
```

Documentation should be generated in a folder called html!

The "source" folder contains the templates to generate the documentation, and can be edited to customize as desired.
4 changes: 4 additions & 0 deletions docs/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 9aeeea96b82e1b044d706099b086a1b0
tags: 645f666f9bcd5a90fca523b33c5a78b7
Empty file added docs/html/.nojekyll
Empty file.
Loading