Show Sidebar Hide Sidebar

Get Requests in Python

How to download plotly users's public graphs and data with python.

import plotly.plotly as py
# Learn about API authentication here: https://plot.ly/python/getting-started
# Find your api_key here: https://plot.ly/settings/api

fig = py.get_figure("https://plot.ly/~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://plot.ly/python/getting-started
# Find your api_key here: https://plot.ly/settings/api

data = py.get_figure("https://plot.ly/~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://plot.ly/~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://plot.ly/python/getting-started
# Find your api_key here: https://plot.ly/settings/api

fig = py.get_figure("https://plot.ly/~PlotBot/5")

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

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

plot_url = py.plot(fig, filename="python-replot2")
Still need help?
Contact Us

For guaranteed 24 hour response turnarounds, upgrade to a Developer Support Plan.