Data Visualization with plotly and cufflinks

#data #visualization

Vishwa Kakadiya Oct 12 2020 · 1 min read
Share this

plotly is one of the powerful visualization library which use to plot attractive graph. with plotly, we can plot many graphs like lines, box plot, histogram and many more.

Cufflinks is another library that connected plotly with pandas to create graphs of the DataFrame directly.

Install the plotly and cufflinks

pip install plotly
pip install cufflinks

import plotly and cufflinks and connected with offline mode

import plotly as py
from plotly.offline import iplot
import cufflinks as cf
py.offline.init_notebook_mode(connected = True)
cf.go_offline()

all example with this data,

import pandas as pd
df = pd.DataFrame(np.random.randn(100,3),columns =['A','B','C']) df.head()

Line plot

df.iplot(x ='A',y = 'B',kind = 'line',mode = 'lines+markers',colors = 'red' )
Line plot

Scatter plot

df.iplot(kind = 'scatter',mode = 'markers')
Scatter plot

Box plot

df.iplot(kind = 'box',theme = 'pearl',boxpoints = 'suspectedoutliers' )
Box plot

Surface pot

df.iplot(kind = 'surface', colorscale = 'bugn')
surface plot

Bar graph

df.iplot(kind = 'bar', barmode='stack', bargap=0.7)
bar graph

Histogram

df.iplot(kind='hist', bins = 25, barmode = 'overlay',colorscale = 'reds')
histogram 

Heatmap

df.iplot(kind='heatmap',colorscale = 'purd')
heatmap

we can get different color scale and theme using these method

cf.getThemes()
cf.colors.scales()
Comments
Read next