我正在自动化几个双周报告,所以我决定使用 plot.ly 创建一个线图。此线图具有不同数量的跟踪,具体取决于正在运行的报告。
我已经能够成功创建绘图,但我发现的所有方法都无法在我的电子邮件中内联显示绘图。这是我的代码:
SMTP_SERVER = "smtp.office365.com"
SMTP_PORT = 587
SMTP_USERNAME = username
SMTP_PASSWORD = password
EMAIL_TO = email_to
EMAIL_FROM = email_from
#here we loop through our data-set and pull out rows to make different traces
for deal in winGraph['DEAL_IDENTIFIER'].unique():
matched_rows = winGraph.loc[winGraph['DEAL_IDENTIFIER'] == deal]
date = matched_rows.DATE.tolist()
winRate = matched_rows.WIN_RATE.tolist()
traces.append(
go.Scatter(
x = date,
y = winRate,
name = str(deal)
)
)
plotly.tools.set_credentials_file(username = 'username', api_key = 'api_key')
fig = dict(data = traces)
imageURL = py.plot(fig,auto_open = False, …Run Code Online (Sandbox Code Playgroud)