Plotly is a library that allows you to create interactive plots that you can use in dashboards or websites (you can save them as html files or static images).
In order for this all to work, you'll need to install plotly and cufflinks to call plots directly off of a pandas dataframe. These libraries are not currently available through conda but are available through pip. Install the libraries at your command line/terminal using:
pip install plotly
pip install cufflinks
NOTE: Make sure you only have one installation of Python on your computer when you do this, otherwise the installation may not work.
In [1]:
import pandas as pd
import numpy as np
%matplotlib inline
In [2]:
from plotly import __version__
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
print(__version__) # requires version >= 1.9.0
In [3]:
import cufflinks as cf
In [4]:
# For Notebooks
init_notebook_mode(connected=True)
In [5]:
# For offline use
cf.go_offline()
In [6]:
df = pd.DataFrame(np.random.randn(100,4),columns='A B C D'.split())
In [22]:
df.head()
Out[22]:
In [39]:
df2 = pd.DataFrame({'Category':['A','B','C'],'Values':[32,43,50]})
In [40]:
df2.head()
Out[40]:
In [20]:
df.iplot(kind='scatter',x='A',y='B',mode='markers',size=10)
In [28]:
df2.iplot(kind='bar',x='Category',y='Values')
In [33]:
df.count().iplot(kind='bar')
In [34]:
df.iplot(kind='box')
In [47]:
df3 = pd.DataFrame({'x':[1,2,3,4,5],'y':[10,20,30,20,10],'z':[5,4,3,2,1]})
df3.iplot(kind='surface',colorscale='rdylbu')
In [50]:
df[['A','B']].iplot(kind='spread')
In [56]:
df['A'].iplot(kind='hist',bins=25)
In [60]:
df.iplot(kind='bubble',x='A',y='B',size='C')
In [13]:
df.scatter_matrix()