Search code examples
pythonplotlydata-visualizationiplots

Plotly: iplot is not working with df.iplot(). How can i make it work?


enter code here
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from sklearn import decomposition
from sklearn import datasets
import seaborn as sns
%matplotlib inline
import plotly as py
import plotly.tools as tls
py.offline.init_notebook_mode(connected=True)
from plotly.offline import iplot


df1=pd.DataFrame(np.random.randn(10,3),columns=['A','B','C'])
df1.iplot()

i am getting error like 'DataFrame' object has no attribute 'iplot' i hope some one could help me, thanks in advance.


Solution

  • There's no need to use iplot anymore. Just set the pandas plotting backend to plotly with pd.options.plotting.backend = "plotly"and use df.plot().

    Here's a setup using your example:

    import pandas as pd
    pd.options.plotting.backend = "plotly"
    
    df1=pd.DataFrame(np.random.randn(10,3),columns=['A','B','C'])
    df1.plot()
    

    enter image description here