# Get this figure: fig = py.get_figure("https://plotly.com/~thalesians/246/") # Get this figure's data: data = py.get_figure("https://plotly.com/~thalesians/246/").get_data() # Add data to this figure: py.plot(Data([Scatter(x=[1, 2], y=[2, 3])]), filename ="labour-conservative-wins-GBPUSD-subplot", fileopt="extend") # Get y data of first trace: y1 = py.get_figure("https://plotly.com/~thalesians/246/").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 = { "line": { "color": "blue", "width": 0.2 }, "mode": "markers+lines", "name": "1979-05-03", "type": "scatter", "x": [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], "y": [100.0, 100.5392392874338, 101.0351468464131, 101.22773230621087, 100.62590274434278, 99.87963408762637, 100.14443909484831, 100.50553683196914, 100.30332209918147, 99.8411169956668, 99.78334135772744, 99.63890226287911, 99.73038035628306, 99.44631680308133, 98.05007221954739, 98.57005296100138, 98.95040924410202, 99.56668271545493, 99.15743861338461, 99.55223880597008, 99.9759268175252, 100.02407318247468, 100.26961964371685, 99.48483389504088, 99.49446316803078, 98.62782859894075, 98.29080404429462, 98.3870967741935, 99.35002407318241, 99.2296581608088, 98.94077997111214, 99.01299951853632, 98.3870967741935, 98.41116995666822, 99.04670197400091, 98.82041405873852, 98.72893596533456, 98.8204140587385, 98.96485315358683, 98.96485315358683, 99.6629754453538], "xaxis": "x1", "yaxis": "y1", "marker": { "size": 5, "color": "blue", "opacity": 0.05 }, "showlegend": True } trace2 = { "line": { "color": "blue", "width": 0.2 }, "mode": "markers+lines", "name": "1983-06-09", "type": "scatter", "x": [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], "y": [100.0, 99.89796569096359, 99.51533703207703, 99.10082265161661, 99.38779414578153, 99.0242969198393, 99.24111982654169, 99.24111982654169, 99.97449142274091, 101.10324596645623, 102.16185192270902, 102.14909763407947, 102.14909763407947, 102.06619475798739, 101.39659460493591, 100.86091448249475, 99.80230852624196, 100.50379440086729, 100.24870862827626, 100.09565716472164, 100.68235444168101, 100.15305146355462, 98.98603405395065, 97.09202219246221, 97.06013647088835, 97.37899368662714, 97.1239079140361, 97.69785090236591, 97.31522224347935, 97.60219373764427, 98.27179389069573, 98.55876538486065, 98.04859383967857, 97.72973662393977, 97.42363369683052, 97.76162234551364, 97.63407945921814, 97.63407945921814, 97.47465085134873, 98.17613672597408, 98.14425100440022], "xaxis": "x1", "yaxis": "y1", "marker": { "size": 5, "color": "blue", "opacity": 0.20833333333333331 }, "showlegend": True } trace3 = { "line": { "color": "blue", "width": 0.2 }, "mode": "markers+lines", "name": "1987-06-11", "type": "scatter", "x": [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], "y": [100.0, 100.02980092978902, 100.35761115746811, 100.28012874001668, 100.3099296698057, 100.07152223149363, 99.7139110740255, 99.7139110740255, 97.38943855048277, 96.13779949934437, 96.8828227440696, 97.12123018238167, 96.80534032661818, 97.95565621647391, 97.92585528668492, 96.74573846704014, 97.2106329717487, 97.65764691858384, 98.99868875908928, 98.84968411014422, 99.01656931696266, 98.46227202288709, 97.27023483132672, 97.38943855048274, 97.40135892239834, 97.13911074025506, 96.31660507807841, 95.06496602694001, 95.30337346525208, 96.67421623554652, 96.08415782572412, 95.9887948503993, 95.41065681249252, 96.12587912742873, 96.28680414828939, 96.28680414828939, 95.9589939206103, 96.46560972702346, 96.55501251639048, 96.42388842531882, 96.40600786744542], "xaxis": "x1", "yaxis": "y1", "marker": { "size": 5, "color": "blue", "opacity": 0.36666666666666664 }, "showlegend": True } trace4 = { "line": { "color": "blue", "width": 0.2 }, "mode": "markers+lines", "name": "1992-04-09", "type": "scatter", "x": [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], "y": [100.0, 99.68492910904953, 100.50177956706928, 101.17859851799989, 100.88103156543555, 99.75494486259407, 99.97666141548514, 100.28589766030689, 100.38508664449499, 101.0560709492969, 100.58929925899992, 101.72705525409881, 101.41781900927707, 101.30696073283154, 100.70599218157419, 100.9452126728514, 101.94877180698991, 101.9954489760196, 102.16465371375224, 102.12381119085126, 103.0981970943462, 102.91732306435613, 102.75978761888089, 102.92315771048483, 102.41554349728688, 101.96627574537602, 101.8145749460295, 102.17632300600965, 102.09463796020768, 102.82396872629671, 103.0106774024155, 103.50662232335605, 103.8041892759204, 103.69333099947484, 103.43077192368277, 103.67582706108868, 104.28263025847477, 103.76334675301936, 104.2009452126728, 104.89526810198957, 104.66188225684108], "xaxis": "x1", "yaxis": "y1", "marker": { "size": 5, "color": "blue", "opacity": 0.525 }, "showlegend": True } trace5 = { "line": { "color": "blue", "width": 0.2 }, "mode": "markers+lines", "name": "2010-05-06", "type": "scatter", "x": [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], "y": [100.0, 100.58900523560209, 100.57591623036647, 100.6609947643979, 101.21727748691099, 101.413612565445, 100.54319371727749, 100.37958115183245, 100.51701570680626, 100.85732984293195, 100.64136125654449, 100.63481675392669, 101.16492146596856, 99.90183246073296, 99.53534031413612, 100.26178010471203, 99.96073298429319, 99.79057591623035, 99.10340314136124, 98.8350785340314, 97.07460732984292, 96.88481675392669, 97.16623036649214, 97.87958115183247, 97.01570680628272, 95.63481675392671, 95.13089005235604, 94.73167539267017, 93.80890052356021, 94.52879581151832, 94.01832460732983, 94.63350785340313, 94.4044502617801, 94.29973821989529, 94.15575916230365, 95.43193717277487, 94.62041884816753, 95.14397905759162, 95.88350785340315, 95.89005235602095, 95.64136125654449], "xaxis": "x1", "yaxis": "y1", "marker": { "size": 5, "color": "blue", "opacity": 0.6833333333333333 }, "showlegend": True } trace6 = { "line": { "color": "blue", "width": 2 }, "mode": "lines", "name": "Conservative Mean", "type": "scatter", "x": [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], "y": [100.0, 100.1481880505676, 100.39742900097772, 100.48877138247354, 100.48541341599187, 100.02974980932511, 99.92786011894358, 100.02921829096798, 99.71761954668821, 99.79540318079844, 100.01258068506516, 100.25529695903863, 100.25315770804262, 100.14577337707182, 99.53477319874871, 99.48784884751126, 99.58947317699595, 99.9203268221873, 99.95742812869966, 99.91429491467602, 99.984926053033, 99.7033067210668, 99.3058876943849, 98.9721400415886, 98.69764914657208, 98.16985226952127, 97.75241477924392, 97.62045962647625, 97.57825114388876, 98.18204735687908, 98.06936110829928, 98.34425622858207, 98.00858124738714, 98.05389564139631, 98.07234937104592, 98.40790938323339, 98.24483576122446, 98.37765790289077, 98.62843247004017, 98.87638701269555, 98.91051088994786], "xaxis": "x1", "yaxis": "y1", "showlegend": True } trace7 = { "line": { "color": "red", "width": 0.2 }, "mode": "markers+lines", "name": "1974-02-28", "type": "scatter", "x": [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], "y": [100.0, 99.58442694663167, 99.01574803149606, 98.33770778652669, 97.7034120734908, 98.09711286089238, 97.92213473315834, 98.09711286089238, 98.09711286089238, 99.14698162729657, 99.45319335083111, 99.6500437445319, 99.6500437445319, 99.82502187226594, 100.06561679790025, 100.39370078740156, 101.29046369203847, 100.26246719160102, 101.09361329833766, 100.63429571303581, 100.67804024496931, 99.99999999999993, 99.71566054243213, 101.66229221347322, 101.92475940507428, 101.59667541557296, 101.57480314960621, 101.57480314960621, 101.79352580927375, 102.71216097987741, 102.60279965004364, 102.0997375328083, 101.9028871391075, 101.96850393700778, 102.58092738407689, 103.23709536307952, 102.40594925634288, 103.52143482064733, 103.67454068241464, 103.89326334208218, 105.07436570428692], "xaxis": "x2", "yaxis": "y2", "marker": { "size": 5, "color": "red", "opacity": 0.05 }, "showlegend": True } trace8 = { "line": { "color": "red", "width": 0.2 }, "mode": "markers+lines", "name": "1974-10-10", "type": "scatter", "x": [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], "y": [100.0, 99.84884474195637, 99.90498812351542, 100.06478082487584, 100.17274886633555, 99.97840639170803, 99.94385661844093, 100.04318721658387, 99.96976894839126, 100.02159360829192, 100.32390412437917, 100.71258907363418, 100.73418268192613, 100.89397538328653, 100.77736989851003, 100.49665299071474, 100.84215072338587, 100.87238177499461, 100.81191967177713, 101.10127402288924, 100.41027855754699, 100.798963506802, 100.798963506802, 100.66940185705032, 100.78600734182682, 100.73850140358456, 100.72986396026775, 100.62189591880801, 100.60462103217446, 100.73418268192616, 100.69099546534225, 100.76441373353487, 100.72554523860934, 100.80760095011874, 100.85078816670261, 100.8637443316778, 100.9717123731375, 101.18764845605696, 101.18764845605696, 101.36903476570932, 101.3344849924422], "xaxis": "x2", "yaxis": "y2", "marker": { "size": 5, "color": "red", "opacity": 0.20833333333333331 }, "showlegend": True } trace9 = { "line": { "color": "red", "width": 0.2 }, "mode": "markers+lines", "name": "1997-05-01", "type": "scatter", "x": [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], "y": [100.0, 99.3617409276032, 98.8936842745122, 98.82681903835633, 98.44386359491824, 98.70524588170933, 98.94231353717099, 98.47425688408, 98.99702145766214, 98.77211111786518, 99.10643729864447, 99.2766397179503, 99.44684213725613, 99.2766397179503, 98.70524588170935, 98.84505501185342, 98.57151540939763, 98.7113245395417, 99.17330253480036, 98.69308856604468, 99.0091787733269, 98.57759406723, 98.6870099082123, 99.31919032277678, 98.1703239924625, 98.39523433225946, 98.65661661905052, 98.69308856604464, 99.17330253480033, 100.07294389398822, 99.86626952768829, 99.4346848215914, 99.69606710838246, 100.62002309889976, 100.17020241930581, 98.73563917087105, 99.35566226977085, 99.69606710838246, 99.23408911312383, 99.68998845055013, 99.65959516138838], "xaxis": "x2", "yaxis": "y2", "marker": { "size": 5, "color": "red", "opacity": 0.36666666666666664 }, "showlegend": True } trace10 = { "line": { "color": "red", "width": 0.2 }, "mode": "markers+lines", "name": "2001-06-07", "type": "scatter", "x": [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], "y": [100.0, 99.78201251670066, 99.85233105970043, 100.1687645031995, 100.61177132409816, 100.6961535756979, 101.22354264819631, 101.27979748259615, 100.37972013219884, 99.80310807960058, 99.00850854370296, 100.02812741719988, 99.86639476830038, 100.08438225159975, 100.28127417199914, 99.73982139090077, 99.73982139090077, 99.45151536460163, 99.41635609310174, 97.92560298150622, 97.9326348358062, 96.92707967090921, 96.52626397581041, 96.65986920751001, 97.88341185570634, 98.54440615990437, 98.66394768300401, 98.77645735180369, 98.5373743056044, 98.14359046480557, 99.52886576190143, 99.3741649673019, 99.36010125870193, 99.51480205330147, 99.66247099360102, 99.06476337810281, 99.52183390760143, 99.68356655650094, 98.96631741790308, 98.93819000070316, 98.64285212010404], "xaxis": "x2", "yaxis": "y2", "marker": { "size": 5, "color": "red", "opacity": 0.525 }, "showlegend": True } trace11 = { "line": { "color": "red", "width": 0.2 }, "mode": "markers+lines", "name": "2005-05-05", "type": "scatter", "x": [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], "y": [100.0, 100.85040380809758, 101.13387174413009, 101.20340161523238, 101.321067550944, 100.63111729154409, 101.23014387334865, 101.82382200352995, 102.59934748890194, 102.65818045675775, 102.07519922982293, 102.39610632721823, 102.21425897202757, 101.93613948761828, 101.93079103599503, 101.93613948761826, 102.09124458469265, 101.35315826068346, 101.21944697010208, 101.75429213242757, 101.98427555222756, 101.10178103439047, 100.7648285821254, 100.6952987110231, 100.17115045194411, 99.76466812857672, 98.97844573995823, 98.33128309354437, 98.07455741562812, 98.42755522276295, 98.28314702893508, 97.72155960849328, 97.8980585120607, 97.73760496336304, 97.96223993153976, 97.34181954324215, 97.57180296304215, 97.53436380167935, 97.18671444616777, 96.77488367117714, 97.0904423169492], "xaxis": "x2", "yaxis": "y2", "marker": { "size": 5, "color": "red", "opacity": 0.6833333333333333 }, "showlegend": True } trace12 = { "line": { "color": "red", "width": 2 }, "mode": "lines", "name": "Labour Mean", "type": "scatter", "x": [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], "y": [100.0, 99.8854857881979, 99.75876364295335, 99.71750400627506, 99.64449205333696, 99.62005453938862, 99.84843561090318, 99.93771128994608, 100.0037518297402, 100.079314077462, 99.99635251641017, 100.41659965061795, 100.38719850550615, 100.40913432762821, 100.35719593980662, 100.28820507119033, 100.51133826673421, 100.13841885177017, 100.35266719019369, 100.02699366421324, 100.00968406252106, 99.48675594833072, 99.30367083366657, 99.8068723903568, 99.79939843134774, 99.82526201344092, 99.7391672972575, 99.61748033873816, 99.65366331439853, 100.032082609261, 100.2139195551899, 99.8979692484265, 99.93751974181733, 100.15027221115619, 100.26536823214659, 99.86176443854252, 99.98710510158207, 100.34103692405718, 100.06179736789846, 100.14134100585466, 100.36161963379755], "xaxis": "x2", "yaxis": "y2", "showlegend": True } trace13 = { "line": { "color": "red", "width": 2 }, "mode": "lines", "name": "Labour Mean", "type": "scatter", "x": [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], "y": [100.0, 99.8854857881979, 99.75876364295335, 99.71750400627506, 99.64449205333696, 99.62005453938862, 99.84843561090318, 99.93771128994608, 100.0037518297402, 100.079314077462, 99.99635251641017, 100.41659965061795, 100.38719850550615, 100.40913432762821, 100.35719593980662, 100.28820507119033, 100.51133826673421, 100.13841885177017, 100.35266719019369, 100.02699366421324, 100.00968406252106, 99.48675594833072, 99.30367083366657, 99.8068723903568, 99.79939843134774, 99.82526201344092, 99.7391672972575, 99.61748033873816, 99.65366331439853, 100.032082609261, 100.2139195551899, 99.8979692484265, 99.93751974181733, 100.15027221115619, 100.26536823214659, 99.86176443854252, 99.98710510158207, 100.34103692405718, 100.06179736789846, 100.14134100585466, 100.36161963379755], "xaxis": "x3", "yaxis": "y3", "showlegend": False } trace14 = { "line": { "color": "blue", "width": 2 }, "mode": "lines", "name": "Conservative Mean", "type": "scatter", "x": [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], "y": [100.0, 100.1481880505676, 100.39742900097772, 100.48877138247354, 100.48541341599187, 100.02974980932511, 99.92786011894358, 100.02921829096798, 99.71761954668821, 99.79540318079844, 100.01258068506516, 100.25529695903863, 100.25315770804262, 100.14577337707182, 99.53477319874871, 99.48784884751126, 99.58947317699595, 99.9203268221873, 99.95742812869966, 99.91429491467602, 99.984926053033, 99.7033067210668, 99.3058876943849, 98.9721400415886, 98.69764914657208, 98.16985226952127, 97.75241477924392, 97.62045962647625, 97.57825114388876, 98.18204735687908, 98.06936110829928, 98.34425622858207, 98.00858124738714, 98.05389564139631, 98.07234937104592, 98.40790938323339, 98.24483576122446, 98.37765790289077, 98.62843247004017, 98.87638701269555, 98.91051088994786], "xaxis": "x3", "yaxis": "y3", "showlegend": False } data = Data([trace1, trace2, trace3, trace4, trace5, trace6, trace7, trace8, trace9, trace10, trace11, trace12, trace13, trace14]) layout = { "title": "GBPUSD during UK gen elects by winning party
Source: @thalesians/BBG/Wikipedia", "xaxis1": { "ticks": "outside", "title": "Days", "anchor": "y1", "domain": [0.0, 0.2888888888888889], "ticklen": 8, "gridcolor": "#FFFFFF", "tickwidth": 1.5 }, "xaxis2": { "ticks": "outside", "title": "Days", "anchor": "y2", "domain": [0.35555555555555557, 0.6444444444444445], "ticklen": 8, "gridcolor": "#FFFFFF", "tickwidth": 1.5 }, "xaxis3": { "ticks": "outside", "title": "Days", "anchor": "y3", "domain": [0.7111111111111111, 1.0], "ticklen": 8, "gridcolor": "#FFFFFF", "tickwidth": 1.5 }, "yaxis1": { "ticks": "outside", "title": "Index", "anchor": "x1", "domain": [0.0, 1.0], "ticklen": 8, "gridcolor": "#FFFFFF", "tickwidth": 1.5 }, "yaxis2": { "ticks": "outside", "anchor": "x2", "domain": [0.0, 1.0], "ticklen": 8, "gridcolor": "#FFFFFF", "tickwidth": 1.5 }, "yaxis3": { "ticks": "outside", "anchor": "x3", "domain": [0.0, 1.0], "ticklen": 8, "gridcolor": "#FFFFFF", "tickwidth": 1.5 }, "plot_bgcolor": "#EFECEA" } fig = Figure(data=data, layout=layout) plot_url = py.plot(fig)