1
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.

vestland
  • 55,229
  • 37
  • 187
  • 305
Os Snehith Ab
  • 67
  • 1
  • 7

2 Answers2

3

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

vestland
  • 55,229
  • 37
  • 187
  • 305
  • 3
    @OsSnehithAb Thank you for accepting my answer! We very often see users who get the help they need, and don't even bother to leave a comment or mark a suggestion as the accepted answer. Now that you have actually done exactly that, other users know that there's working solution to this post, and I don't have to keep coming back to it and see what's going on. So it's a very useful and time-saving thing to do. Thanks again! – vestland Oct 16 '20 at 13:25
  • i hope u can answer my other question as well, please help https://stackoverflow.com/questions/64390205/how-to-represent-data-in-a-graph-using-matplotlib-plt-plotdf-by-smoothening-th – Os Snehith Ab Oct 16 '20 at 14:06
  • 1
    @OsSnehithAb That's a [matplotlib] question, and far from my area of expertise. If you'd like to build a similar solution for [plotly] I'll have a look at it. – vestland Oct 16 '20 at 17:43
0

To supplement the accepted answer from @vestland: if you are plotting several figures, you may not want to use Plotly as the default backend for the whole session.

To use Plotly for a specific figure only:

import pandas as pd

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

df1.plot(backend="plotly")  # Plot using Plotly
df1.plot()  # Plot using the session backend (which is "matplotlib" by default)