# Get this figure: fig = py.get_figure("https://plotly.com/~etpinard/5613/") # Get this figure's data: data = py.get_figure("https://plotly.com/~etpinard/5613/").get_data() # Add data to this figure: py.plot(Data([Scatter(x=[1, 2], y=[2, 3])]), filename ="discrete-colorscale2", fileopt="extend") # Get z data of first trace: z1 = py.get_figure("https://plotly.com/~etpinard/5613/").get_data()[0]["z"] # Get figure documentation: https://plotly.com/python/get-requests/ # Add data documentation: https://plotly.com/python/file-options/ # If you're using unicode in your file, you may need to specify the encoding. # You can reproduce this figure in Python with the following code! # Learn about API authentication here: https://plotly.com/python/getting-started # Find your api_key here: https://plotly.com/settings/api import plotly.plotly as py from plotly.graph_objs import * py.sign_in('username', 'api_key') trace1 = { "type": "choropleth", "zmax": 10, "zmin": 0, "z": [1.0, 2.0, 3.0, 3.0, 3.0, 3.0, 5.0, 6.0], "text": ["1.0CO", "2.0OR", "3.0ID", "3.0KY", "3.0MT", "3.0PA", "5.0MD", "6.0TN"], "colorbar": { "x": 0.9, "y": 0.2, "len": 0.2, "dtick": 10, "tick0": 0 }, "colorscale": [ [0, "#ffffcc"], [1, "#ffffcc], "locationmode": "USA-states", "locations": ["CO", "OR", "ID", "KY", "MT", "PA", "MD", "TN"] } trace2 = { "type": "choropleth", "zmax": 100, "zmin": 10, "z": [11.0, 12.0, 15.0, 17.0, 19.0, 20.0, 23.0, 24.0, 26.0, 27.0, 27.0, 36.0, 36.0, 42.0, 42.0, 52.0, 52.0, 55.0, 56.0, 61.0, 71.0, 84.0, 89.0], "text": ["11.0IL", "12.0CA", "15.0DE", "17.0SD", "19.0IN", "20.0MS", "23.0NH", "24.0WY", "26.0AR", "27.0LA", "27.0NM", "36.0AZ", "36.0NE", "42.0NC", "42.0SC", "52.0OH", "52.0UT", "55.0AL", "56.0GA", "61.0WA", "71.0NV", "84.0MO", "89.0FL"], "colorbar": { "x": 0.9, "y": 0.4, "len": 0.2, "dtick": 90, "tick0": 10 }, "colorscale": [ [0, "#addd8e"], [1, "#addd8e], "locationmode": "USA-states", "locations": ["IL", "CA", "DE", "SD", "IN", "MS", "NH", "WY", "AR", "LA", "NM", "AZ", "NE", "NC", "SC", "OH", "UT", "AL", "GA", "WA", "NV", "MO", "FL"] } trace3 = { "type": "choropleth", "zmax": 1000, "zmin": 100, "z": [109.0, 112.0, 129.0], "text": ["109.0VA", "112.0OK", "129.0CT"], "colorbar": { "x": 0.9, "y": 0.6000000000000001, "len": 0.2, "dtick": 900, "tick0": 100 }, "colorscale": [ [0, "#78c679"], [1, "#78c679], "locationmode": "USA-states", "locations": ["VA", "OK", "CT"] } trace4 = { "type": "choropleth", "zmax": 1500, "zmin": 1000, "z": [1281.0], "text": ["1281.0TX"], "colorbar": { "x": 0.9, "y": 0.8, "len": 0.2, "dtick": 500, "tick0": 1000 }, "colorscale": [ [0, "#31a354"], [1, "#31a354], "locationmode": "USA-states", "locations": ["TX"] } data = Data([trace1, trace2, trace3, trace4]) layout = { "geo": { "scope": "usa", "lakecolor": "rgb(255, 255, 255)", "showlakes": False, "projection": {"type": "albers usa"} }, "title": "Executions by U.S. State Since 1819", "width": 701, "height": 518, "autosize": True } fig = Figure(data=data, layout=layout) plot_url = py.plot(fig)