#!/usr/bin/env python # coding: utf-8 # ##Cufflinks # # This library binds the power of [plotly](http://www.plot.ly) with the flexibility of [pandas](http://pandas.pydata.org/) 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](https://plot.ly/python/getting-started/) guide. # In[1]: import cufflinks as cf # In[2]: get_ipython().run_line_magic('reload_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') # In[3]: #We set the all charts as public cf.set_config_file(sharing='public',theme='pearl',offline=False) # ## Line Chart # In[4]: cf.datagen.lines().iplot(kind='scatter',xTitle='Dates',yTitle='Returns',title='Cufflinks - Line Chart') # In[7]: cf.datagen.lines(3).iplot(kind='scatter',xTitle='Dates',yTitle='Returns',title='Cufflinks - Filled Line Chart', colorscale='-blues',fill=True) # In[8]: 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']) # ## Scatter Chart # In[9]: cf.datagen.lines(2).iplot(kind='scatter',mode='markers',size=10,symbol='x',colorscale='paired', xTitle='Dates',yTitle='EPS Growth',title='Cufflinks - Scatter Chart') # ## Spread Chart # In[10]: cf.datagen.lines(2).iplot(kind='spread',xTitle='Dates',yTitle='Return',title='Cufflinks - Spread Chart') # ## Bar Chart # In[11]: cf.datagen.lines(5).resample('M').iplot(kind='bar',xTitle='Dates',yTitle='Return',title='Cufflinks - Bar Chart') # In[12]: cf.datagen.lines(5).resample('M').iplot(kind='bar',xTitle='Dates',yTitle='Return',title='Cufflinks - Grouped Bar Chart', barmode='stack') # ## Box Plot # In[13]: cf.datagen.box(6).iplot(kind='box',xTitle='Stocks',yTitle='Returns Distribution',title='Cufflinks - Box Plot') # ## Historgram # In[14]: cf.datagen.histogram(2).iplot(kind='histogram',opacity=.75,title='Cufflinks - Histogram') # ##Heatmap Plot # In[15]: cf.datagen.heatmap(20,20).iplot(kind='heatmap',colorscale='spectral',title='Cufflinks - Heatmap') # ##Bubble Chart # In[16]: 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') # ##Scatter 3D # In[29]: cf.datagen.scatter3d(2,150,mode='stocks').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), opacity=1) # ##Bubble 3D # In[28]: cf.datagen.bubble3d(5,4,mode='stocks').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=.9) # ##Surface # In[30]: cf.datagen.sinwave(10,.25).iplot(kind='surface',theme='solar',colorscale='brbg',title='Cufflinks - Surface Plot', margin=(0,0,0,0)) # In[ ]: