答案 0 :(得分:0)
你需要将plot.ly传递给一个字典,如下所示:
py.iplot({'data': [xyz]})
您放入xyz
的内容取决于您想要制作的图表。请参阅Plotly's Getting Started Gide。
答案 1 :(得分:0)
可以使用iplot()
作为带有以下代码的条形图或线图(使用Jupyter Notebook
用Python 3
编写)来绘制数据。
# Import libraries
import pandas as pd
import numpy as np
import datetime
import matplotlib.pyplot as plt
import seaborn as sns
%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()
# Create an example dataframe
df = pd.DataFrame({'issue_d': ['2007-06-01', '2007-07-01', '2007-08-01', '2007-09-01', '2007-10-01'],
'loan_amt': [91850.0, 348325.0, 515300, 372950.0, 753225.0]
})
# Convert date string to datetime
df['issue_d'] = pd.to_datetime(df['issue_d'])
# Create line plot
df.iplot(kind='line', x='issue_d', y='loan_amt', xTitle= 'Issue date', yTitle= 'Loan amount', title='Loan Amounts', width=4)
# Create bar plot
df.iplot(kind='bar', x='issue_d', y='loan_amt', xTitle= 'Issue date', yTitle= 'Loan amount', title='Loan Amounts')