Issue
What is the difference between plot() and iplot() in displaying a figure in Jupyter Notebook?
Solution
I just started using iplot() in Python (3.6.6). I think it uses the Cufflinks wrapper over plotly that runs Matplotlib under the hood. It is seems to be the easiest way for me to get interactive plots with simple one line code.
Although it needs some libraries to setup. For example, the code below works in Jupyter Notebook (5.0.0) on macOS. The plots attached here are PNG and therefore not interactive.
Example: (1) Line plot (2) Bar plot {code below}
# Import libraries
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)
init_notebook_mode(connected=True)
cf.go_offline()
# Create random data
df = pd.DataFrame(np.random.randn(100,4), columns='Col1 Col2 Col3 Col4'.split())
df.head(2)
# Plot lines
df.iplot()
# Plot bars
df.iplot(kind='bar')
Answered By - Nilesh Ingle
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.