Working With Chart Studio Graphs in Python
How to download Chart Studio users' public graphs and data into Python.
New to Plotly?
Plotly is a free and open-source graphing library for Python. We recommend you read our Getting Started guide for the latest installation or upgrade instructions, then move on to our Plotly Fundamentals tutorials or dive straight in to some Basic Charts tutorials.
Get and Change a Public Figure¶
In [1]:
import chart_studio.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!"
py.iplot(fig, filename="python-change_plot")
Out[1]:
Get Data and Change Plot¶
In [2]:
import chart_studio.plotly as py
import plotly.graph_objects 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/~PythonPlotBot/3483").data
distance = [d['y'][0] for d in data] # check out the data for yourself!
fig = go.Figure()
fig.add_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.update_layout(title="data source: https://plotly.com/~AlexHP/68", xaxis=xaxis, yaxis=yaxis)
plot_url = py.plot(fig, filename="python-get-data")
Get and Replot a Public Figure with URL¶
In [3]:
import chart_studio.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")
Get and Replot a Public Figure with ID¶
In [4]:
import chart_studio.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")