This library binds the power of plotly with the flexibility of pandas for easy plotting.
This library is available on https://github.com/santosjorge/cufflinks
This tutorial assumes that the plotly user credentials have already been configured as stated on the getting started guide.
import cufflinks as cf
%reload_ext autoreload
%autoreload 2
cf.datagen.lines().iplot(kind='scatter',xTitle='Dates',yTitle='Returns',title='Cufflinks - Line Chart',
world_readable=True)
/Users/Jorge/anaconda/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
cf.datagen.lines(3).iplot(kind='scatter',xTitle='Dates',yTitle='Returns',title='Cufflinks - Filled Line Chart',
colorscale='-blues',fill=True,world_readable=True)
/Users/Jorge/anaconda/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
cf.datagen.lines(1).iplot(kind='scatter',xTitle='Dates',yTitle='Returns',title='Cufflinks - Besfit Line Chart',
filename='Cufflinks - Bestfit Line Chart',bestfit=True,colors=['blue'],
bestfit_colors=['pink'],world_readable=True)
/Users/Jorge/anaconda/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
cf.datagen.lines(2).iplot(kind='scatter',mode='markers',size=10,symbol='x',colorscale='paired',
xTitle='Dates',yTitle='EPS Growth',title='Cufflinks - Scatter Chart',
world_readable=True)
/Users/Jorge/anaconda/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
cf.datagen.lines(2).iplot(kind='spread',xTitle='Dates',yTitle='Return',title='Cufflinks - Spread Chart',
world_readable=True)
/Users/Jorge/anaconda/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
cf.datagen.lines(5).resample('M').iplot(kind='bar',xTitle='Dates',yTitle='Return',title='Cufflinks - Bar Chart',
world_readable=True)
/Users/Jorge/anaconda/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
cf.datagen.lines(5).resample('M').iplot(kind='bar',xTitle='Dates',yTitle='Return',title='Cufflinks - Grouped Bar Chart',
barmode='stack',world_readable=False)
/Users/Jorge/anaconda/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
cf.datagen.box(6).iplot(kind='box',xTitle='Stocks',yTitle='Returns Distribution',title='Cufflinks - Box Plot',
world_readable=True)
/Users/Jorge/anaconda/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
cf.datagen.histogram(2).iplot(kind='histogram',opacity=.75,title='Cufflinks - Histogram',
linecolor='white',world_readable=True)
/Users/Jorge/anaconda/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
cf.datagen.heatmap(20,20).iplot(kind='heatmap',colorscale='spectral',title='Cufflinks - Heatmap',
world_readable=True)
/Users/Jorge/anaconda/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
cf.datagen.bubble(prefix='industry').iplot(kind='bubble',x='x',y='y',size='size',categories='categories',text='text',
xTitle='Returns',yTitle='Analyst Score',title='Cufflinks - Bubble Chart',
world_readable=True)
/Users/Jorge/anaconda/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
cf.datagen.scatter3d(2,150).iplot(kind='scatter3d',x='x',y='y',z='z',size=15,categories='categories',text='text',
title='Cufflinks - Scatter 3D Chart',colors=['blue','pink'],width=0.5,margin=(0,0,0,0),
world_readable=True)
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-14-71f2b24fb7bb> in <module>() 1 cf.datagen.scatter3d(2,150).iplot(kind='scatter3d',x='x',y='y',z='z',size=15,categories='categories',text='text', 2 title='Cufflinks - Scatter 3D Chart',colors=['blue','pink'],width=0.5,margin=(0,0,0,0), ----> 3 world_readable=True) /Users/Jorge/Dropbox/Development/Git/repos/cufflinks/cufflinks/plotlytools.pyc in _iplot(self, data, layout, filename, world_readable, kind, title, xTitle, yTitle, zTitle, theme, colors, colorscale, fill, width, mode, symbol, size, barmode, sortbars, boxpoints, annotations, keys, bestfit, bestfit_colors, categories, x, y, z, text, gridcolor, zerolinecolor, margin, asFrame, asDates, asFigure, asImage, dimensions, asPlot, asUrl, **kwargs) 514 line=Line(width=width)),textfont=getLayout(theme=theme)['xaxis']['titlefont']) 515 if '3d' in kind: --> 516 _data=Scatter3d(x=_x,y=_y,z=_z.values,mode=mode,name=_, 517 marker=Marker(color=colors[_],symbol=symbol,size=_size,opacity=opacity, 518 line=Line(width=width)),textfont=getLayout(theme=theme)['xaxis']['titlefont']) AttributeError: 'numpy.ndarray' object has no attribute 'values'
cf.datagen.bubble3d(5,4).iplot(kind='bubble3d',x='x',y='y',z='z',size='size',text='text',categories='categories',
title='Cufflinks - Bubble 3D Chart',colorscale='set1',
width=.5,opacity=.8,world_readable=True)
cf.datagen.sinwave(10,.25).iplot(kind='surface',theme='solar',colorscale='brbg',title='Cufflinks - Surface Plot',
margin=(0,0,0,0),world_readable=True)