Artificial Intelligence in Plain English

New AI, ML and Data Science articles every day. Follow to join our 3.5M+ monthly readers.

Follow publication

Interactive data visualization using Plotly and Cufflinks

--

What are Plotly and cufflinks?

How to install Plotly and Cufflinks?

pip install plotly

pip install cufflinks

How to import packages?

>>> import pandas as pd
>>> import numpy as np
>>> import plotly
>>> import cufflinks as cf
>>> from plotly.offline import download_plotlyjs,init_notebook_mode,plot,iplot
>>> init_notebook_mode(connected=True)
>>> cf.go_offline()

How to create dataframes?

>>> dataset1 = pd.DataFrame(np.random.randn(100,4),columns='a b c d'.split())
>>> dataset1.head()
>>> dataset2=pd.DataFrame({'Key':['a','b','c'], 'Value':[11,22,33]})
>>> dataset2.head()
>>> dataset3 = pd.DataFrame({'a':[11,22,33,44,55],'b':[10,20,30,10,20],'c':[5,4,3,2,1]})
>>> dataset3.head()

How to create line plots?

>>> dataset1.iplot()

How to create scatter plots?

>>> dataset1.iplot(kind='scatter',x='a',y='c')
>>> dataset1.iplot(kind='scatter',x='a',y='c',mode='markers')

How to create bar plots?

>>> dataset2.iplot(kind='bar',x='Key',y='Value')
>>> dataset1.count().iplot(kind='bar')
>>> dataset1.sum().iplot(kind='bar')

How to create box plots?

>>> dataset1.iplot(kind='box')

How to create surface plots?

>>> dataset3.iplot(kind='surface')
>>> dataset3.iplot(kind='surface',colorscale='rdylbu')

How to create histograms?

>>> dataset1['d'].iplot(kind='hist', bins=30)
>>> dataset1.iplot(kind='hist')

How to create spread plots?

>>> dataset1[['a','d']].iplot(kind='spread')

How to create bubble plots?

>>> dataset1.iplot(kind='bubble',x='a',y='b',size='c')

How to create scatter matrix plot?

>>> dataset1.scatter_matrix()

For more detailed information on Plotly and Cufflinks, check the official documentation here and here respectively.

Refer to the notebook for code here.

Books to refer to:

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Published in Artificial Intelligence in Plain English

New AI, ML and Data Science articles every day. Follow to join our 3.5M+ monthly readers.

Written by Jayashree domala

Self-driven woman who wishes to deliver creative and engaging ideas and solutions in the field of technology.

No responses yet