# Get this figure: fig = py.get_figure("https://plotly.com/~ggplot2examples/98/") # Get this figure's data: data = py.get_figure("https://plotly.com/~ggplot2examples/98/").get_data() # Add data to this figure: py.plot(Data([Scatter(x=[1, 2], y=[2, 3])]), filename ="from api (32)", fileopt="extend") # Get y data of first trace: y1 = py.get_figure("https://plotly.com/~ggplot2examples/98/").get_data()[0]["y"] # 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 = { "uid": "fec647", "line": { "dash": "solid", "color": "rgb(248,118,109)", "shape": "spline", "width": 3 }, "mode": "lines", "name": "Chile", "text": None, "type": "scatter", "x": [1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012], "y": [None, None, 600, 640, 660, 650, 740, 760, 770, 800, 860, 1020, 1110, 1320, 1620, 1120, 980, 1070, 1320, 1740, 2240, 2640, 2190, 1780, 1600, 1410, 1410, 1560, 1820, 2090, 2240, 2490, 3020, 3330, 3610, 4320, 4930, 5380, 5250, 4910, 4920, 4760, 4550, 4570, 5230, 6250, 7260, 8630, 10020, 9930, 10720, 12270, 14310], "marker": {"line": }}, "error_x": }, "error_y": }, "textfont": } } trace2 = { "uid": "10a1c6", "line": { "dash": "solid", "color": "rgb(0,186,56)", "shape": "spline", "width": 3 }, "mode": "lines", "name": "Hungary", "text": None, "type": "scatter", "x": [1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012], "y": [None, None, None, None, None, None, None, None, None, None, 540, 590, 670, 830, 1000, 1150, 1200, 1330, 1520, 1770, 2070, 2200, 2170, 2010, 1930, 1860, 2040, 2400, 2710, 2770, 2880, 2740, 3140, 3630, 4000, 4220, 4320, 4370, 4380, 4460, 4580, 4720, 5210, 6550, 8540, 10220, 11040, 11510, 12890, 12980, 12930, 12900, 12410], "marker": {"line": }}, "error_x": }, "error_y": }, "textfont": } } trace3 = { "uid": "f5a68f", "line": { "dash": "solid", "color": "rgb(97,156,255)", "shape": "spline", "width": 3 }, "mode": "lines", "name": "Uruguay", "text": None, "type": "scatter", "x": [1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012], "y": [None, None, 580, 610, 660, 680, 720, 640, 610, 670, 820, 850, 870, 1060, 1370, 1620, 1490, 1420, 1630, 2150, 2870, 3650, 3290, 2190, 1740, 1510, 1780, 2210, 2600, 2730, 2840, 3180, 3830, 4350, 5040, 5530, 6160, 6970, 7240, 7260, 7050, 6500, 5140, 4240, 4130, 4720, 5380, 6380, 7690, 8520, 10110, 11700, 13580], "marker": {"line": }}, "error_x": }, "error_y": }, "textfont": } } data = Data([trace1, trace2, trace3]) layout = { "font": { "size": 12, "color": "#444", "family": "\"Open sans\", verdana, arial, sans-serif" }, "smith": False, "title": "Click to enter Plot title", "width": 1255, "xaxis": { "type": "linear", "dtick": 10, "range": [1960, 2012], "tick0": 0, "ticks": "", "title": "year", "anchor": "y", "domain": [0, 1], "mirror": False, "nticks": 0, "ticklen": 5, "autotick": True, "position": 0, "showgrid": True, "showline": False, "tickfont": { "size": 0, "color": "", "family": "" }, "zeroline": False, "autorange": True, "gridcolor": "rgb(255,255,255)", "gridwidth": 1, "linecolor": "#444", "linewidth": 1, "rangemode": "normal", "tickangle": "auto", "tickcolor": "rgb(127,127,127)", "tickwidth": 1, "titlefont": { "size": 0, "color": "", "family": "" }, "overlaying": False, "showexponent": "all", "zerolinecolor": "#444", "zerolinewidth": 1, "exponentformat": "B", "showticklabels": True }, "yaxis": { "type": "linear", "dtick": 2000, "range": [-225.00000000000023, 15075], "tick0": 0, "ticks": "", "title": "NY.GNP.PCAP.CD", "anchor": "x", "domain": [0, 1], "mirror": False, "nticks": 0, "ticklen": 5, "autotick": True, "position": 0, "showgrid": True, "showline": False, "tickfont": { "size": 0, "color": "", "family": "" }, "zeroline": False, "autorange": True, "gridcolor": "rgb(255,255,255)", "gridwidth": 1, "linecolor": "#444", "linewidth": 1, "rangemode": "normal", "tickangle": "auto", "tickcolor": "rgb(127,127,127)", "tickwidth": 1, "titlefont": { "size": 0, "color": "", "family": "" }, "overlaying": False, "showexponent": "all", "zerolinecolor": "#444", "zerolinewidth": 1, "exponentformat": "B", "showticklabels": True }, "bargap": 0.2, "boxgap": 0.3, "height": 492, "legend": { "x": 1.02, "y": 0.5, "font": { "size": 0, "color": "", "family": "" }, "bgcolor": "#fff", "xanchor": "left", "yanchor": "auto", "traceorder": "normal", "bordercolor": "transparent", "borderwidth": 0 }, "margin": { "b": 80, "l": 80, "r": 10, "t": 100, "pad": 0, "autoexpand": True }, "barmode": "group", "boxmode": "overlay", "autosize": True, "dragmode": "zoom", "hovermode": "x", "titlefont": { "size": 0, "color": "", "family": "" }, "separators": ".,", "showlegend": True, "bargroupgap": 0, "boxgroupgap": 0.3, "hidesources": False, "plot_bgcolor": "rgb(229,229,229)", "paper_bgcolor": "#fff" } fig = Figure(data=data, layout=layout) plot_url = py.plot(fig)