# Get this figure: p = download_plot("https://plotly.com/~Dreamshot/2565/")
# Get this figure's data: data = download_plot("https://plotly.com/~Dreamshot/2565/").plot.data
# Add data to this figure: post(plot(scatter(x=[1, 2], y=[2, 3])); filename="Population Trends", fileopt="extend"))
# Get y data of first trace: y1 = download_plot("https://plotly.com/~Dreamshot/2565/").plot.data[1]["y"]
# Get figure documentation: https://plotly.com/julia/get-requests/
# Add data documentation: https://plotly.com/julia/file-options/
# You can reproduce this figure in Julia with the following code!
# Learn about API authentication here: https://plotly.com/julia/getting-started
# Find your api_key here: https://plotly.com/settings/api
using Plotly
Plotly.signin("username", "api_key")
trace1 = scatter(Dict(
:uid => "e47b54",
:line => Dict(
:color => "rgb(148, 103, 189)",
:shape => "spline",
:width => 4
),
:mode => "lines",
:name => "North America",
:type => "scatter",
:x => ["1952-3-8", "1972-4-30", "1986-11-23", "2000-12-21", "2012-11-12", "2025-9-24", "2038-11-2", "2049-7-8", "2060-9-6", "2073-10-15", "2085-3-13", "2098-7-19"],
:y => [0.18691588785046953, 0.2429906542056095, 0.2803738317757034, 0.3364485981308416, 0.35514018691588944, 0.3925233644859816, 0.4299065420560755, 0.44859813084112155, 0.4859813084112172, 0.5046728971962633, 0.5046728971962633, 0.5233644859813094]
))
trace2 = scatter(Dict(
:uid => "62c2fe",
:line => Dict(
:shape => "spline",
:width => 4
),
:mode => "lines",
:name => "Latin America & the Caribbean",
:type => "scatter",
:x => ["1952-3-8", "1972-4-30", "1986-11-23", "2000-12-21", "2012-11-12", "2025-9-24", "2038-11-2", "2049-7-8", "2060-9-6", "2073-10-15", "2085-3-13", "2098-7-19"],
:y => ["0.18691588785046953", "0.2990654205607495", "0.4112149532710294", "0.5420560747663572", "0.6168224299065432", "0.7102803738317771", "0.7663551401869171", "0.803738317757011", "0.803738317757011", "0.7850467289719631", "0.7663551401869171", "0.747663551401871"]
))
trace3 = scatter(Dict(
:uid => "b31779",
:line => Dict(
:color => "rgb(255, 0, 255)",
:shape => "spline",
:width => 4
),
:mode => "lines",
:name => "Africa",
:type => "scatter",
:x => ["1952-3-8", "1972-4-30", "1986-11-23", "2000-12-21", "2012-11-12", "2025-9-24", "2038-11-2", "2049-7-8", "2060-9-6", "2073-10-15", "2085-3-13", "2098-7-19"],
:y => ["0.2429906542056095", "0.3925233644859816", "0.5794392523364493", "0.822429906542057", "1.1028037383177587", "1.4953271028037385", "1.925233644859814", "2.3177570093457955", "2.7476635514018692", "3.4018691588785064", "3.794392523364486", "4.186915887850468"]
))
trace4 = scatter(Dict(
:uid => "48ee99",
:line => Dict(
:color => "rgb(106, 168, 79)",
:shape => "spline",
:width => 4
),
:mode => "lines",
:name => "Asia",
:type => "scatter",
:x => ["1952-3-8", "1972-4-30", "1986-11-23", "2000-12-21", "2012-11-12", "2025-9-24", "2038-11-2", "2049-7-8", "2060-9-6", "2073-10-15", "2085-3-13", "2098-7-19"],
:y => ["1.4018691588785064", "2.1682242990654217", "2.953271028037383", "3.738317757009346", "4.261682242990656", "4.691588785046731", "5.028037383177571", "5.158878504672899", "5.158878504672899", "5.028037383177571", "4.897196261682245", "4.728971962616823"]
))
trace5 = scatter(Dict(
:uid => "4341c8",
:line => Dict(
:color => "rgb(67, 67, 67)",
:shape => "spline",
:width => 4
),
:mode => "lines",
:name => "World",
:type => "scatter",
:x => ["1952-3-8", "1972-4-30", "1986-11-23", "2000-12-21", "2012-11-12", "2025-9-24", "2038-11-2", "2049-7-8", "2060-9-6", "2073-10-15", "2085-3-13", "2098-7-19"],
:y => ["2.5607476635514015", "3.8130841121495322", "4.915887850467291", "6.205607476635516", "7.177570093457946", "8", "8.971962616822431", "9.532710280373834", "10.037383177570096", "10.52336448598131", "10.766355140186917", "10.971962616822431"]
))
trace6 = scatter(Dict(
:uid => "a81a70",
:line => Dict(
:color => "rgba(106, 168, 79, 0)",
:shape => "spline",
:width => 4
),
:mode => "lines",
:name => "95% C.I.",
:type => "scatter",
:x => ["1952-3-8", "1972-4-30", "1986-11-23", "2000-12-21", "2012-11-12", "2025-9-24", "2038-11-2", "2049-7-8", "2060-9-6", "2073-10-15", "2085-3-13", "2098-7-19"],
:y => ["2.5607476635514015", "3.8130841121495322", "4.915887850467291", "6.205607476635516", "7.177570093457946", "8.074766355140188", "9.177570093457945", "9.869158878504674", "10.560747663551403", "11.401869158878505", "11.88785046728972", "12.448598130841122"],
:showlegend => false
))
trace7 = scatter(Dict(
:uid => "f1e76f",
:fill => "tonexty",
:line => Dict(
:color => "rgba(217, 217, 217, 0)",
:shape => "spline",
:width => 4
),
:mode => "lines",
:name => "95% C.I.",
:type => "scatter",
:x => ["1952-3-8", "1972-4-30", "1986-11-23", "2000-12-21", "2012-11-12", "2025-9-24", "2038-11-2", "2049-7-8", "2060-9-6", "2073-10-15", "2085-3-13", "2098-7-19"],
:y => ["2.5607476635514015", "3.8130841121495322", "4.915887850467291", "6.205607476635516", "7.177570093457946", "7.925233644859814", "8.766355140186917", "9.233644859813085", "9.55140186915888", "9.757009345794394", "9.77570093457944", "9.700934579439252"],
:showlegend => false
))
trace8 = scatter(Dict(
:uid => "7aec79",
:line => Dict(
:color => "rgb(61, 133, 198)",
:shape => "spline",
:width => 4
),
:mode => "lines",
:name => "Europe",
:type => "scatter",
:x => ["1952-3-8", "1972-4-30", "1986-11-23", "2000-12-21", "2012-11-12", "2025-9-24", "2038-11-2", "2049-7-8", "2060-9-6", "2073-10-15", "2085-3-13", "2098-7-19"],
:y => ["0.5607476635514033", "0.6542056074766354", "0.7102803738317771", "0.747663551401871", "0.747663551401871", "0.747663551401871", "0.7289719626168232", "0.7102803738317771", "0.691588785046731", "0.6728971962616832", "0.6542056074766354", "0.6542056074766354"]
))
trace9 = scatter(Dict(
:uid => "91fe66",
:line => Dict(
:dash => "dot",
:color => "rgb(102, 102, 102)",
:shape => "spline",
:width => 4
),
:mode => "lines",
:name => "World (old projection)",
:type => "scatter",
:x => ["2000-9-23", "2018-12-7", "2036-5-29", "2051-12-11", "2067-12-19", "2081-10-19", "2098-4-22"],
:y => ["6.149532710280376", "7.551401869158879", "8.504672897196262", "8.971962616822431", "9.102803738317757", "8.953271028037385", "8.485981308411215"]
))
trace10 = scatter(Dict(
:uid => "cb36b6",
:line => Dict(
:color => "rgba(23, 190, 207, 0)",
:shape => "spline",
:width => 4
),
:mode => "lines",
:name => "C.I.",
:type => "scatter",
:x => ["", "", "", "", "", "", "2038-11-2", "2049-7-8", "2060-9-6", "2073-10-15", "2085-3-13", "2098-7-19"],
:y => ["", "", "", "", "", "", "9.1176", "10.204213357238903", "10.960824742268038", "11.791035410129984", "12.584311967727473", "13.340385477364407"],
:showlegend => false
))
trace11 = scatter(Dict(
:uid => "02f2d9",
:fill => "tonexty",
:line => Dict(
:color => "rgba(31, 119, 180, 0)",
:shape => "spline",
:width => 4
),
:mode => "lines",
:name => "C.I.",
:type => "scatter",
:x => ["", "", "", "", "", "", "2038-11-2", "2049-7-8", "2060-9-6", "2073-10-15", "2085-3-13", "2098-7-19"],
:y => ["", "", "", "", "", "", "8.766355140186917", "9.109636934110261", "9.291169878978035", "9.378574630210666", "9.30004482294935", "9.090900941281934"],
:fillcolor => "rgba(217, 217, 217, 0.5)",
:showlegend => false
))
data = [trace1, trace2, trace3, trace4, trace5, trace6, trace7, trace8, trace9, trace10, trace11]
layout = Layout(Dict(
:title => "
World Population Projections",
:width => 700,
:xaxis => Dict(
:type => "date",
:range => [-562262400000, 4056591600000],
:title => "Source: Scientific American",
:showgrid => false,
:showline => true,
:zeroline => false,
:autorange => true
),
:yaxis => Dict(
:side => "right",
:type => "linear",
:range => [-0.5438324226780826, 14.07113378789296],
:title => "Total Population (billions)",
:showgrid => false,
:showline => true,
:zeroline => false,
:autorange => true
),
:height => 800,
:legend => Dict(
:x => 0.0171875,
:y => 1.019047619047619
),
:autosize => false,
:showlegend => false,
:annotations => [
Dict(
:x => 3617415457291.667,
:y => 11.368150789808851,
:text => "World
(new projection)",
:showarrow => false,
:textangle => 0
),
Dict(
:x => 960505228125,
:y => 4.362620519442196,
:font => Dict(:color => "rgb(106, 168, 79)"),
:text => "Asia",
:showarrow => false,
:textangle => -30
),
Dict(
:x => 1891492987500,
:y => 2.100780510663344,
:font => Dict(:color => "rgb(255, 0, 255)"),
:text => "Africa",
:showarrow => false,
:textangle => -20
),
Dict(
:x => 217158412500,
:y => 1.056854352765412,
:font => Dict(:color => "rgb(61, 133, 198)"),
:text => "Europe",
:showarrow => false
),
Dict(
:x => 3161677837500,
:y => 1.2656395843449983,
:font => Dict(:color => "rgb(255, 127, 14)"),
:text => "Latin America and the Caribbean",
:showarrow => false
),
Dict(
:x => 1913143865625,
:y => 0.012928194867480869,
:font => Dict(:color => "rgb(148, 103, 189)"),
:text => "North America",
:showarrow => false
),
Dict(
:x => 2132058300000,
:y => 8.380052475481655,
:ax => -13,
:ay => 66,
:text => "Dotted Line:
International Institute
for Applied Systems
Analysis 2001 projection",
:arrowhead => 0
),
Dict(
:x => 935379517708.3333,
:y => 6.404450284190945,
:ax => -31,
:ay => -37,
:text => "Solid Lines:
U.N. 2014
projections",
:arrowhead => 0
),
Dict(
:x => 3047275666666.667,
:y => 8.673025300440106,
:text => "World
(old projection)",
:showarrow => false
)
]
))
p = plot(data, layout)
response = post(p)
plot_url = response.url