Black Lives Matter. Please consider donating to Black Girls Code today.

Documentation opens every time I make a plot

I’m running a python script on a cron job (ubuntu server in python virtualenv) and every time I generate a plot I am greeted with the documentation (at bottom; opens in w3m via SSH), which blocks my script from finishing. What’s frustrating is the plot is being uploaded and is visible from my online profile. How do it set this to not open EVERY time i generate a plot?
I’ve done the
plotly.tools.set_credentials_file(username=‘DemoAccount’, api_key=‘lr19g7zw81’) #with actual credentials

Code:

import plotly
import pandas as pd

data = pd.read_csv(‘data’)
t1 = plotly.graph_objs.Scatter(name=‘Value’, x=data.DateTime, y=data.Value, line=plotly.graph_objs.Line(color=‘blue’))
t2 = plotly.graph_objs.Scatter(name=‘Value 2’, x=data.DateTime, y=data.Value2, yaxis=‘y2’, line=plotly.graph_objs.Line(color=‘green’))
data = [t1, t2, t3, t4, t5]
layout = {‘title’: “graph”,
‘yaxis’: {‘title’: “Value”, ‘domain’:[0.5,1]},
‘yaxis2’: {‘title’: “Value2”, ‘domain’:[0.0, 0.5]},
‘xaxis’: {‘anchor’:‘y2’}}
fig = plotly.graph_objs.Figure(data=data, layout=layout)
plotly.offline.plot(fig, filename=‘figure.html’, auto_open=False)
plotly.plotly.plot(fig, filename=‘Figure’)

plotly
Sign In SIGN UP UPGRADE REQUEST DEMO
[français]
Feed Pricing Make a Chart
Help
Feed Pricing Make a Chart Help
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Sign In Sign up Upgrade

Plotly is the collaboration platform for modern data science.

Set up a private Plotly cloud at your company.

API

• API Home
• Python
• R
• MATLAB
• JavaScript

Hi there,

I was unable to reproduce the error on my end (I was using Python 2/3 on OS X) but I have a few suspicious about why the documentation is popping up.

Firstly, why is the plot being generated twice at the bottom there?

plotly.offline.plot(fig, filename='figure.html', auto_open=False)
plotly.plotly.plot(fig, filename='Figure')

Try removing one of those and see what you get.

Also, and a separate question, but have you defined t3, t4 and t5 at an earlier point in the script? I had to just use data = [t1, t2] to make my script work.

Hey thanks,

I actually figured this out a day or two ago and forgot about this post - auto_open needed to be set to false for the online plot (i wanted an offline and online copy on every script run). Since there were no graphical browsers installed, it was opening the web page in the same terminal the script was running in and blocking the remainder of the script

[t3, t4, t5] were all there, it was just a shoddily simplified version of my code