Working With Chart Studio Graphs in Python/v3

How to download Chart Studio users' public graphs and data with Python.


Note: this page is part of the documentation for version 3 of Plotly.py, which is not the most recent version.
See our Version 4 Migration Guide for information about how to upgrade.
The version 4 version of this page is here.
import plotly.plotly as py
# Learn about API authentication here: https://plotly.com/python/getting-started
# Find your api_key here: https://plotly.com/settings/api

fig = py.get_figure("https://plotly.com/~PlotBot/5")

fig['layout']['title'] = "Never forget that title!"

plot_url = py.plot(fig, filename="python-change_plot")
import plotly.plotly as py
import plotly.graph_objs as go
# Learn about API authentication here: https://plotly.com/python/getting-started
# Find your api_key here: https://plotly.com/settings/api

data = py.get_figure("https://plotly.com/~AlexHP/68").get_data()
distance = [d['y'][0] for d in data]  # check out the data for yourself!

fig = go.Figure()
fig['data'] += [go.Histogram(y=distance, name="flyby distance", histnorm='probability')]
xaxis = dict(title="Probability for Flyby at this Distance")
yaxis = dict(title="Distance from Earth (Earth Radii)")
fig['layout'].update(title="data source: https://plotly.com/~AlexHP/68", xaxis=xaxis, yaxis=yaxis)

plot_url = py.plot(fig, filename="python-get-data")
import plotly.plotly as py
# Learn about API authentication here: https://plotly.com/python/getting-started
# Find your api_key here: https://plotly.com/settings/api

fig = py.get_figure("https://plotly.com/~PlotBot/5")

plot_url = py.plot(fig, filename="python-replot1")
import plotly.plotly as py
# Learn about API authentication here: https://plotly.com/python/getting-started
# Find your api_key here: https://plotly.com/settings/api

fig = py.get_figure("PlotBot", 5)

plot_url = py.plot(fig, filename="python-replot2")