본문 바로가기

Data Science/Visualization

[plotly] iplot in Python

1. What is iplot?

iplot() uses the Cufflinks wrapper over plotly that runs Matplotlib under the hood. It's seems to be the easiest way to get iteractive plots with simple one line code.

 

2. Differences between iplot and plot

iplot is iteractive plot. Plotly takes Python code and makes beautiful looking JavaScript plots. plot coommand is Matplotlib which is more old-school. It creates static charts. So there is not much hover information really, and we have to rerun the code to change anything.

 

3. How to use iplot

# Importing libraries to use iplot 

import pandas as pd 
import numpy as np 
from plotly import __version__ 
%matplotlib inline 

import cufflinks as cf 
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot 

init_notebook_mode(connected = True)
cf.go_offline() 

# Visualization 

df = pd.DataFrame(np.random.randn(100, 4), columns = 'Col1 Col2 Col3 Col4'.split())

df.iplot()
df.iplot(kind = 'bar')