# Get this figure: fig = py.get_figure("https://plotly.com/~tccorrigan1/9/") # Get this figure's data: data = py.get_figure("https://plotly.com/~tccorrigan1/9/").get_data() # Add data to this figure: py.plot(Data([Scatter(x=[1, 2], y=[2, 3])]), filename ="Nielsen Rating for Top TV Show by Season, 1950-2015 (copy) (2)", fileopt="extend") # Get y data of first trace: y1 = py.get_figure("https://plotly.com/~tccorrigan1/9/").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 = { "x": ["50–51", "51–52", "52–53", "53–54", "54–55", "55–56", "56–57", "57–58", "58–59", "59–60", "60–61", "61–62", "62–63", "63–64", "64–65", "65–66", "66–67", "67–68", "68–69", "69–70", "70–71", "71–72", "72–73", "73–74", "74–75", "75–76", "76–77", "77–78", "78–79", "79–80", "80–81", "81–82", "82–83", "83–84", "84–85", "85–86", "86–87", "87–88", "88–89", "89–90", "90–91", "91–92", "92–93", "93–94", "94–95", "95–96", "96–97", "97–98", "98–99", "99–00", "00–01", "01–02", "02–03", "03–04", "04–05", "05–06", "06–07", "07–08", "08–09", "09–10", "10–11", "11–12", "12–13", "13–14", "14–15", "15-16"], "y": ["61.6", "53.8", "67.3", "58.8", "49.3", "47.5", "43.7", "43.1", "39.6", "40.3", "37.3", "32.1", "36", "39.1", "36.3", "31.8", "29.1", "27.6", "31.8", "26.3", "29.6", "34", "33.3", "31.2", "30.2", "30.1", "31.5", "31.6", "30.5", "28.4", "34.5", "28.4", "25.5", "25.7", "25", "33.7", "34.9", "27.8", "25.6", "23.1", "21.3", "21.9", "21.9", "20.9", "20.6", "22", "21.2", "21.7", "17.8", "18.6", "17.4", "15", "16.3", "15.9", "16.5", "17.6", "17.3", "16.1", "15.1", "13.7", "14.5", "12.4", "13.5", "12.6", "12.3", "-"], "uid": "6cbcef", "mode": "lines+markers", "name": "Rating", "text": ["Texaco Star Theater", "Arthur Godfrey's Talent Scouts", "I Love Lucy", "I Love Lucy", "I Love Lucy", "The $64,000 Question", "I Love Lucy", "Gunsmoke", "Gunsmoke", "Gunsmoke", "Gunsmoke", "Wagon Train", "The Beverly Hillbillies", "The Beverly Hillbillies", "Bonanza", "Bonanza", "Bonanza", "The Andy Griffith Show", "Rowan & Martin's Laugh-In", "Rowan & Martin's Laugh-In", "Marcus Welby, M.D.", "All in the Family", "All in the Family", "All in the Family", "All in the Family", "All in the Family", "Happy Days", "Laverne & Shirley", "Laverne & Shirley", "60 Minutes", "Dallas", "Dallas", "60 Minutes", "Dallas", "Dynasty", "The Cosby Show", "The Cosby Show", "The Cosby Show", "The Cosby Show", "The Cosby Show & Rosanne (tie)", "Cheers", "60 Minutes", "60 Minutes", "60 Minutes", "Seinfeld", "ER", "ER", "Seinfeld", "ER", "Who Wants to Be a Millionaire? — Tuesdays", "Survivor: The Australian Outback", "Friends", "CSI: Crime Scene Investigation", "CSI: Crime Scene Investigation", "CSI: Crime Scene Investigation", "American Idol — Tuesday", "American Idol — Wednesday", "American Idol — Tuesday", "American Idol — Wednesday", "American Idol — Tuesday", "American Idol — Wednesday", "Sunday Night Football", "NCIS", "Sunday Night Football & NCIS (tie)", "Sunday Night Football", "-"], "type": "scatter", "xsrc": "tccorrigan1:0:a97151", "ysrc": "tccorrigan1:0:3c5efc", "xbins": { "end": 64.5, "size": 1, "start": -0.5 }, "domain": {"y": [0.01]}, "marker": { "line": { "color": "#444", "width": 0 }, "color": "#1f77b4", "colors": "#1f77b4" }, "error_x": {"copy_ystyle": True}, "error_y": { "color": "rgb(0, 67, 88)", "width": 1, "thickness": 1 }, "opacity": 1, "textsrc": "tccorrigan1:0:7fda7c", "autobinx": True, "autobiny": True, "hoverinfo": "all" } data = Data([trace1]) layout = { "font": { "size": 12, "color": "#444", "family": "\"Open Sans\", verdana, arial, sans-serif" }, "title": "Nielsen Rating for Top TV Show by Season, 1960-2015", "width": 952, "xaxis": { "type": "category", "dtick": 5, "range": [9.685596016054227, 68.98142795745926], "tick0": 0, "ticks": "inside", "title": "Season", "tickmode": "linear", "autorange": False, "tickangle": 40 }, "yaxis": { "type": "linear", "range": [8.552434746262016, 45.79925499421842], "title": "Nielsen Rating", "autorange": False }, "bargap": 0.2, "height": 502, "legend": { "x": 0.02, "y": 1, "bgcolor": "rgba(255, 255, 255, 0.5)" }, "autosize": True, "dragmode": "zoom", "hovermode": "x", "titlefont": { "size": 17, "color": "#444", "family": "\"Open Sans\", verdana, arial, sans-serif" }, "separators": ".,", "annotations": [ { "x": 3.0290404040404013, "y": 67.12057392476247, "ax": 58, "ay": 23, "font": { "size": 14, "color": "#444", "family": "\"Open Sans\", verdana, arial, sans-serif" }, "text": "I Love Lucy", "bgcolor": "rgba(0, 0, 0, 0)", "opacity": 1, "arrowhead": 1, "arrowsize": 1, "borderpad": 1, "textangle": 0, "arrowcolor": "#444", "arrowwidth": 2, "bordercolor": "rgba(0, 0, 0, 0)", "borderwidth": 1 }, { "x": 13.3, "y": 40.24923864282554, "ax": 42, "ay": -31, "font": { "size": 14, "color": "#444", "family": "\"Open Sans\", verdana, arial, sans-serif" }, "text": "The Beverly Hillbillies", "bgcolor": "rgba(0, 0, 0, 0)", "opacity": 1, "arrowhead": 1, "arrowsize": 1, "borderpad": 1, "textangle": 0, "arrowcolor": "#444", "arrowwidth": 2, "bordercolor": "rgba(0, 0, 0, 0)", "borderwidth": 1 }, { "x": 6.499655422794511, "y": 42.15823014080041, "ax": -26, "ay": 31, "font": { "size": 14, "color": "#444", "family": "\"Open Sans\", verdana, arial, sans-serif" }, "text": "Gunsmoke", "bgcolor": "rgba(0, 0, 0, 0)", "opacity": 1, "arrowhead": 1, "arrowsize": 1, "borderpad": 1, "textangle": 0, "arrowcolor": "#444", "arrowwidth": 2, "bordercolor": "rgba(0, 0, 0, 0)", "borderwidth": 1 }, { "x": 21.330808080808076, "y": 35.362089000359866, "ax": 24, "ay": -39, "font": { "size": 14, "color": "#444", "family": "\"Open Sans\", verdana, arial, sans-serif" }, "text": "All in the Family", "bgcolor": "rgba(0, 0, 0, 0)", "opacity": 1, "arrowhead": 1, "arrowsize": 1, "borderpad": 1, "textangle": 0, "arrowcolor": "#444", "arrowwidth": 2, "bordercolor": "rgba(0, 0, 0, 0)", "borderwidth": 1 }, { "x": 30.076515151515153, "y": 35.680583812472356, "ax": 12, "ay": -30, "font": { "size": 14, "color": "#444", "family": "\"Open Sans\", verdana, arial, sans-serif" }, "text": "Dallas", "bgcolor": "rgba(0, 0, 0, 0)", "opacity": 1, "arrowhead": 1, "arrowsize": 1, "borderpad": 1, "textangle": 0, "arrowcolor": "#444", "arrowwidth": 2, "bordercolor": "rgba(0, 0, 0, 0)", "borderwidth": 1 }, { "x": 36.43181818181818, "y": 36.24359418824738, "ax": 24, "ay": -30, "font": { "size": 14, "color": "#444", "family": "\"Open Sans\", verdana, arial, sans-serif" }, "text": "The Cosby Show", "bgcolor": "rgba(0, 0, 0, 0)", "opacity": 1, "arrowhead": 1, "arrowsize": 1, "borderpad": 1, "textangle": 0, "arrowcolor": "#444", "arrowwidth": 2, "bordercolor": "rgba(0, 0, 0, 0)", "borderwidth": 1 }, { "x": 44.55681818181818, "y": 23.359887479019065, "ax": -24, "ay": -30, "font": { "size": 14, "color": "#444", "family": "\"Open Sans\", verdana, arial, sans-serif" }, "text": "ER", "bgcolor": "rgba(0, 0, 0, 0)", "opacity": 1, "arrowhead": 1, "arrowsize": 1, "borderpad": 1, "textangle": 0, "arrowcolor": "#444", "arrowwidth": 2, "bordercolor": "rgba(0, 0, 0, 0)", "borderwidth": 1 }, { "x": 47.34722222222222, "y": 23.359887479019065, "ax": 24, "ay": -30, "font": { "size": 14, "color": "#444", "family": "\"Open Sans\", verdana, arial, sans-serif" }, "text": "Seinfeld", "bgcolor": "rgba(0, 0, 0, 0)", "opacity": 1, "arrowhead": 1, "arrowsize": 1, "borderpad": 1, "textangle": 0, "arrowcolor": "#444", "arrowwidth": 2, "bordercolor": "rgba(0, 0, 0, 0)", "borderwidth": 1 }, { "x": 54.733585858585855, "y": 19.393114133525263, "font": { "size": 14, "color": "#444", "family": "\"Open Sans\", verdana, arial, sans-serif" }, "text": "American Idol", "bgcolor": "rgba(0, 0, 0, 0)", "opacity": 1, "arrowhead": 1, "arrowsize": 1, "borderpad": 1, "textangle": 0, "arrowcolor": "#444", "arrowwidth": 2, "bordercolor": "rgba(0, 0, 0, 0)", "borderwidth": 1 }, { "x": 17.935063093718984, "y": 32.981013106624154, "font": {"size": 14}, "text": "Laugh-In" }, { "x": 39.531546859492416, "y": 19.60552944509444, "ax": -24, "ay": 30, "font": {"size": 14}, "text": "Cheers" }, { "x": 50.39275485608961, "y": 13.803365214311015, "ax": -52, "ay": 14, "font": {"size": 14}, "text": "Friends" }, { "x": 61.67247979583156, "y": 14.641303577754158, "ax": -31, "ay": -30, "font": {"size": 14}, "text": "NCIS" }, { "x": 63.85027647809443, "y": 13.498193411264609, "ax": -36, "ay": -112, "font": {"size": 14}, "text": "Sunday Night Football" } ], "bargroupgap": 0, "hidesources": False, "plot_bgcolor": "#fff", "paper_bgcolor": "#fff" } fig = Figure(data=data, layout=layout) plot_url = py.plot(fig)