Data Visualization with Plotly offline

Simple steps for using plotly offline in Jupyter Notebook

Introduction

plotly.py is an interactive, open-source, and browser-based graphing library for Python it makes ploti

Steps

  • installing libraries
  • importing libraries
  • Configuring plotly in Jupyter notebook for offline mode
  • taking plottly for a spin

Requirements

  • Chrome Browser [very important for offline plot]
  • jupyter notebook
  • Plotly module
  • cufflinks module
The cufflinks library binds the power of plotly with the flexibility of pandas for easy plotting

Step 1

  • Installing Libraries
#installing required libraries  in jupyter notebook
!pip install plotly
!pip install cufflinks
Skip step 1 if you already have them installed

Step 2

  • Importing Libraries
#importing  libraries
import plotly
import cufflinks as cf

Step 3

  • Configuring plotly in Jupyter notebook for offline mode
# importing plotly offline
from plotly.offline import iplot
# cugglinks offline
cf.go_offline()
# allowing plotly to display inside jupyter notebook
plotly.offline.init_notebook_mode(connected=False)
passing connected = True means that plotly should connect to the internet

Step 4

  • Taking plotly for a spin
#importing libraries
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
#generating data set
df = pd.DataFrame(np.random.randn(100,3), columns = ['A', 'B', 'C'])
df['A'] = df['A'].cumsum() + 20
df['B'] = df['B'].cumsum() + 20
df['C'] = df['C'].cumsum() + 20
df.head()
# plotting a line plot
df.iplot()
#plotting a box plot
df.iplot(kind='box')

Thank You