Skip to content

Instantly share code, notes, and snippets.

@eagleEggs
Last active August 11, 2018 02:42
Show Gist options
  • Save eagleEggs/c441ffa88a90a8a360d771fae3ba2d8e to your computer and use it in GitHub Desktop.
Save eagleEggs/c441ffa88a90a8a360d771fae3ba2d8e to your computer and use it in GitHub Desktop.
plotly offline graph from command line
Setting up the following will enable running a notebook from CLI and create a plotly image from the generated graph:
CLI:
sudo jupyter nbconvert --execute notebook.ipynb
Python:
At top of notebook: offline.init_notebook_mode()
After defining data and figure:
offline.iplot(fig, filename='graph', image='png')
@eagleEggs
Copy link
Author

py.offline.iplot({‘data’: data, ‘layout’: layout}, filename=‘plot_name’, image=‘png’)

Need to test:

from plotly.offline import init_notebook_mode, plot_mpl
import matplotlib.pyplot as plt

init_notebook_mode()

fig = plt.figure()
x = [10, 15, 20, 25, 30]
y = [100, 250, 200, 150, 300]
plt.plot(x, y, "o")

plot_mpl(fig)
# If you want to to download an image of the figure as well
plot_mpl(fig, image='png')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment