Created
July 21, 2017 19:18
-
-
Save flamingbear/90538a168c6430baf266b8a9363fa582 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plotly.plotly as py | |
import plotly.graph_objs as go | |
import numpy as np | |
from pandas import RangeIndex | |
from numpy import array | |
data = [{'hoverinfo': 'y', | |
'line': {'color': 'transparent'}, | |
'name': '± 2 Standard Deviations', | |
'showlegend': False, | |
'type': 'scatter', | |
'x': RangeIndex(start=0, stop=153, step=1), | |
'y': [6.1385010592558364, | |
6.2346535706439541, | |
6.3332496833695204, | |
6.437343024435636, | |
6.5425604717155714, | |
6.6472008878963829, | |
6.7506480665897097, | |
6.8518375089904975, | |
6.9543296393945102, | |
7.0572402660190807, | |
7.1685213553673357, | |
7.280495061123549, | |
7.3999318643482752, | |
7.5174381174403813, | |
7.6329994900021791, | |
7.7445111498256809, | |
7.85224588193425, | |
7.9523881868467043, | |
8.050707388654649, | |
8.155856878122588, | |
8.2667806367170265, | |
8.378640890418616, | |
8.4878868262000591, | |
8.5964264225024003, | |
8.7032978782793595, | |
8.8031042285989436, | |
8.898469865078372, | |
8.9968218968615474, | |
9.0964872276960396, | |
9.1897834463259684, | |
9.2848844471531287, | |
9.3912240006188625, | |
9.4954921958572349, | |
9.6032514636928017, | |
9.718441761443481, | |
9.8391605458869424, | |
9.9563830091573955, | |
10.076092180679428, | |
10.195672301616794, | |
10.316396606422774, | |
10.430408598202751, | |
10.542186136667182, | |
10.65021233090363, | |
10.751873006420814, | |
10.853207969855296, | |
10.955977487648239, | |
11.061102612984389, | |
11.170243060929387, | |
11.282432112378606, | |
11.391372330907718, | |
11.506537680084074, | |
11.617414901067983, | |
11.725148383991433, | |
11.839374231124227, | |
11.958785289121105, | |
12.07650514067597, | |
12.206153448471309, | |
12.341594396019206, | |
12.474700880767195, | |
12.599472570988542, | |
12.712997819259771, | |
12.804441373252125, | |
12.880875167630945, | |
12.949212480150813, | |
13.019250664326959, | |
13.091840744751179, | |
13.172432068293208, | |
13.266373556019589, | |
13.362908883076193, | |
13.469361343891842, | |
13.582598720689786, | |
13.700412152674044, | |
13.812110160527652, | |
13.921726779297749, | |
14.026659682013356, | |
14.119476934313841, | |
14.206875029443699, | |
14.296382026225213, | |
14.393644454262155, | |
14.478939368477135, | |
14.567949950198907, | |
14.657858933856581, | |
14.747926060127883, | |
14.831026900296227, | |
14.922696936032995, | |
15.016299624856062, | |
15.10790306396796, | |
15.18922433615187, | |
15.263565940132207, | |
15.331453518232024, | |
15.394000195878709, | |
15.459749031053569, | |
15.532764851068368, | |
15.608069653457292, | |
15.683549526207464, | |
15.762810536525306, | |
15.846731435011773, | |
15.92926119760472, | |
16.009186985984492, | |
16.083210956273401, | |
16.158593079132064, | |
16.224154893777069, | |
16.298025118941723, | |
16.383039180800353, | |
16.464105678759172, | |
16.53098704708831, | |
16.596593703215746, | |
16.655486750703538, | |
16.700294932010525, | |
16.756151614630312, | |
16.822475336116224, | |
16.892976505144659, | |
16.959121724310641, | |
17.033461209385383, | |
17.10772816738011, | |
17.176527302144379, | |
17.236345371026907, | |
17.293767349027249, | |
17.351499065820338, | |
17.405896485098374, | |
17.461141540536623, | |
17.522223683462119, | |
17.585945610848096, | |
17.643469696590824, | |
17.698925582843085, | |
17.759577232770624, | |
17.822085874509639, | |
17.888102017048332, | |
17.96012251669779, | |
18.038184024899735, | |
18.117814332802613, | |
18.185982235354334, | |
18.247547593828177, | |
18.302064175660483, | |
18.352051795201351, | |
18.392660788340624, | |
18.438341182140519, | |
18.476002765738858, | |
18.517232735847681, | |
18.545264352011536, | |
18.566730830749581, | |
18.576900337963334, | |
18.593313489415475, | |
18.601586316397103, | |
18.61002667452458, | |
18.631502401355185, | |
18.667163775800365, | |
18.70379911564013, | |
18.741415079486156, | |
18.785198634106674, | |
18.824915073908429, | |
18.859503132825029, | |
18.885703835913947]}, | |
{'fill': 'tonexty', | |
'fillcolor': 'rgba(240, 240, 240, 1)', | |
'hoverinfo': 'y', | |
'line': {'color': 'transparent'}, | |
'name': '± 2 Standard Deviations', | |
'type': 'scatter', | |
'x': RangeIndex(start=0, stop=153, step=1), | |
'y': [4.1304118495708311, | |
4.2136793906093795, | |
4.2998122433571462, | |
4.3831138599910311, | |
4.4736938324377622, | |
4.5665896857302846, | |
4.6644694879836273, | |
4.7670021795561706, | |
4.8715424386188246, | |
4.9724412041675894, | |
5.0704635728859984, | |
5.1688000899364521, | |
5.2619223031850595, | |
5.3566910195596211, | |
5.4566504873844881, | |
5.5581792686409832, | |
5.6678669022724151, | |
5.7836382663399597, | |
5.9006431913453481, | |
6.01399726993741, | |
6.1240886427696415, | |
6.2276924739613815, | |
6.332374346546608, | |
6.4395831002975985, | |
6.5477648737139749, | |
6.6610559784677221, | |
6.7790988112149604, | |
6.8974368043317886, | |
7.0163609597439613, | |
7.1415426853273649, | |
7.2663860239735349, | |
7.3817292536011356, | |
7.4952304028960981, | |
7.6056594583672013, | |
7.7119571325898546, | |
7.8135865062730643, | |
7.9191702678026124, | |
8.0273553735339114, | |
8.1343324059965436, | |
8.2324416709038957, | |
8.3325012268639167, | |
8.4384287178861523, | |
8.5431462778230394, | |
8.6559695245191914, | |
8.7752368282513711, | |
8.8960967443650976, | |
9.0129108729289484, | |
9.1254156449239474, | |
9.2300103055280669, | |
9.3387533165056169, | |
9.4479695273225968, | |
9.5567215255386859, | |
9.6662815930952366, | |
9.7717349230291095, | |
9.8667842171255682, | |
9.953455737737368, | |
10.028770858982028, | |
10.098595690454134, | |
10.170726287706145, | |
10.24997293027813, | |
10.341585154046905, | |
10.465279216974547, | |
10.611289226915725, | |
10.760952939742523, | |
10.906209064099714, | |
11.049385966948821, | |
11.178356452306794, | |
11.289163780707083, | |
11.394223969563813, | |
11.496542977708161, | |
11.591856350676887, | |
11.678491180312623, | |
11.765803967252346, | |
11.85347237950225, | |
11.941424916119971, | |
12.043121220532818, | |
12.151646222402961, | |
12.261991068974776, | |
12.373702505477837, | |
12.496441581389519, | |
12.61452646171441, | |
12.730042781583403, | |
12.841730742078765, | |
12.953760763550424, | |
13.059917268033658, | |
13.159482107657256, | |
13.256982413292025, | |
13.358260671961453, | |
13.45986328516112, | |
13.566142762627965, | |
13.675560137234614, | |
13.786297427739754, | |
13.892634961778285, | |
13.993782071049363, | |
14.08527572187252, | |
14.167214411448013, | |
14.233637221128209, | |
14.2984654184486, | |
14.363746366942157, | |
14.432132854719924, | |
14.504643218001261, | |
14.582888494236258, | |
14.663742235671602, | |
14.748531422572974, | |
14.845123253827488, | |
14.949235777438345, | |
15.053394305917577, | |
15.148996016249789, | |
15.236553879642802, | |
15.310558288636351, | |
15.383311755023772, | |
15.462252109095344, | |
15.555930142696027, | |
15.654941643354613, | |
15.751317700753219, | |
15.836910421555622, | |
15.915233251666429, | |
15.981081632499425, | |
16.036809866132995, | |
16.089016010534962, | |
16.148004694783381, | |
16.203183700957883, | |
16.252454369951909, | |
16.307746035969178, | |
16.363256844856924, | |
16.407305178609384, | |
16.446758618523695, | |
16.484172770291678, | |
16.519065591028887, | |
16.55557533972695, | |
16.592031801310736, | |
16.635168863739015, | |
16.677960332478502, | |
16.72038732095286, | |
16.758653532525326, | |
16.799160814952717, | |
16.843044164672833, | |
16.899168120454494, | |
16.951615301679002, | |
17.004898356055143, | |
17.056785230223763, | |
17.10645664786335, | |
17.146737404124533, | |
17.193198054402906, | |
17.240048750755431, | |
17.278871804398165, | |
17.309271960879652, | |
17.345056128039886, | |
17.379972261880521, | |
17.406516060773345, | |
17.437782943384917, | |
17.47074901652832, | |
17.499245666499402]}, | |
{'hoverinfo': 'y', | |
'line': {'color': 'rgba(150, 150, 150, 1)', 'width': 3}, | |
'name': '1981-2010 Average', | |
'type': 'scatter', | |
'x': RangeIndex(start=0, stop=153, step=1), | |
'y': [5.1344564544133338, | |
5.2241664806266668, | |
5.3165309633633333, | |
5.4102284422133335, | |
5.5081271520766668, | |
5.6068952868133337, | |
5.7075587772866685, | |
5.809419844273334, | |
5.9129360390066674, | |
6.0148407350933351, | |
6.119492464126667, | |
6.2246475755300006, | |
6.3309270837666674, | |
6.4370645685000012, | |
6.5448249886933336, | |
6.6513452092333321, | |
6.7600563921033325, | |
6.868013226593332, | |
6.975675289999999, | |
7.0849270740299994, | |
7.1954346397433335, | |
7.3031666821899988, | |
7.4101305863733335, | |
7.5180047613999994, | |
7.6255313759966672, | |
7.7320801035333329, | |
7.8387843381466666, | |
7.9471293505966685, | |
8.0564240937200005, | |
8.1656630658266671, | |
8.2756352355633318, | |
8.3864766271099995, | |
8.4953612993766665, | |
8.6044554610300015, | |
8.7151994470166674, | |
8.8263735260800029, | |
8.9377766384800044, | |
9.0517237771066696, | |
9.1650023538066687, | |
9.274419138663335, | |
9.381454912533334, | |
9.490307427276667, | |
9.5966793043633345, | |
9.7039212654700027, | |
9.8142223990533335, | |
9.9260371160066683, | |
10.037006742956669, | |
10.147829352926667, | |
10.256221208953336, | |
10.365062823706667, | |
10.477253603703335, | |
10.587068213303334, | |
10.695714988543335, | |
10.805554577076668, | |
10.912784753123336, | |
11.014980439206669, | |
11.117462153726668, | |
11.22009504323667, | |
11.32271358423667, | |
11.424722750633336, | |
11.527291486653338, | |
11.634860295113336, | |
11.746082197273335, | |
11.855082709946668, | |
11.962729864213337, | |
12.07061335585, | |
12.175394260300001, | |
12.277768668363336, | |
12.378566426320003, | |
12.482952160800002, | |
12.587227535683336, | |
12.689451666493333, | |
12.788957063889999, | |
12.8875995794, | |
12.984042299066664, | |
13.08129907742333, | |
13.17926062592333, | |
13.279186547599995, | |
13.383673479869996, | |
13.487690474933327, | |
13.591238205956659, | |
13.693950857719992, | |
13.794828401103324, | |
13.892393831923325, | |
13.991307102033327, | |
14.087890866256659, | |
14.182442738629993, | |
14.273742504056662, | |
14.361714612646663, | |
14.448798140429995, | |
14.534780166556661, | |
14.623023229396662, | |
14.712699906423326, | |
14.800925862253328, | |
14.884412624039992, | |
14.965012473986659, | |
15.040184328069991, | |
15.11386330802666, | |
15.186466676463326, | |
15.257671905496663, | |
15.331618148566664, | |
15.403521694006663, | |
15.480883677306663, | |
15.565785301686663, | |
15.65461446629333, | |
15.740111412263328, | |
15.82499400456666, | |
15.902241383476664, | |
15.968424405826664, | |
16.033354951633331, | |
16.102893545569998, | |
16.177614307120002, | |
16.257525933503334, | |
16.344201426369999, | |
16.429522934066664, | |
16.50671886185, | |
16.575789311346668, | |
16.637424490763337, | |
16.694154465976666, | |
16.747456247816668, | |
16.804573117660002, | |
16.862703692210001, | |
16.919199990400003, | |
16.975607866280001, | |
17.031091213850004, | |
17.083441205690004, | |
17.134422246516667, | |
17.186137393670005, | |
17.239594053863339, | |
17.296879682313342, | |
17.354923067056674, | |
17.410575549546675, | |
17.462753963153339, | |
17.511225748306671, | |
17.555352663863339, | |
17.595910801646671, | |
17.640692673406676, | |
17.687585443096676, | |
17.734424018763342, | |
17.77508135403334, | |
17.811758030486672, | |
17.841678492913342, | |
17.870025446770004, | |
17.897392185400005, | |
17.925037712640005, | |
17.955187102876675, | |
17.988217868340008, | |
18.024427621840008, | |
18.060693670683339, | |
18.09585734744001, | |
18.131349008646673, | |
18.165126074676675, | |
18.192474751206674]}, | |
{'hoverinfo': 'y', | |
'line': {'color': 'rgb(3, 88, 38)', 'width': 3}, | |
'name': '2016', | |
'type': 'scatter', | |
'x': RangeIndex(start=0, stop=153, step=1), | |
'y': array([ 5.61662271, 5.71185861, 5.80100695, 5.8809468 , | |
5.97384208, 6.0790845 , 6.16935409, 6.25489841, | |
6.33919233, 6.4120679 , 6.47605429, 6.55812826, | |
6.65384324, 6.76346775, 6.89576835, 7.04018984, | |
7.18107503, 7.30687039, 7.40462371, 7.49010884, | |
7.57353276, 7.65225836, 7.74044139, 7.8641708 , | |
7.98305647, 8.09816785, 8.21331303, 8.31086518, | |
8.3957213 , 8.47832816, 8.56191546, 8.64900568, | |
8.75942638, 8.86538811, 8.96427988, 9.06402046, | |
9.15244308, 9.22981158, 9.31296895, 9.39108237, | |
9.46359531, 9.53284324, 9.60997299, 9.68184897, | |
9.77158631, 9.87252211, 9.99286779, 10.0989835 , | |
10.22132626, 10.33281422, 10.44345058, 10.5324565 , | |
10.62120093, 10.69397375, 10.77474688, 10.82624392, | |
10.89193508, 10.96002346, 11.00852535, 11.04586717, | |
11.11291444, 11.18554955, 11.26524008, 11.38235897, | |
11.50734391, 11.64778859, 11.79552244, 11.9480159 , | |
12.08704574, 12.23548713, 12.35804474, 12.48118015, | |
12.61128641, 12.75088906, 12.90034156, 13.04577768, | |
13.1793159 , 13.29580054, 13.40158841, 13.30958807, | |
13.4146744 , 13.51480489, 13.62223408, 13.72252803, | |
13.99623661, 14.07320101, 14.1479898 , 14.22276521, | |
14.30035485, 14.39262719, 14.49734767, 14.60725842, | |
14.68204615, 14.74956414, 14.81755512, 14.89474168, | |
14.99549513, 15.1412288 , 15.28553446, 15.42236555, | |
15.54723358, 15.64973713, 15.74103891, 15.8281413 , | |
15.90567199, 15.96475445, 16.00692137, 16.02913565, | |
16.05990645, 16.08359964, 16.1111924 , 16.13399805, | |
16.18569602, 16.24340495, 16.32130386, 16.39718604, | |
16.48694934, 16.56522504, 16.6186083 , 16.66271289, | |
16.72655894, 16.77622129, 16.81699565, 16.86602314, | |
16.91849498, 16.95498878, 16.99937775, 17.0495452 , | |
17.10500375, 17.16645144, 17.2554353 , 17.33924503, | |
17.42129154, 17.51384695, 17.59448622, 17.64636837, | |
17.71232845, 17.77924151, 17.83204212, 17.87640688, | |
17.9469324 , 18.00875171, 18.07006216, 18.13509129, | |
18.1784273 , 18.06549291, 18.08583466, 18.1181939 , | |
18.14766062, 18.21868578, 18.40441151, 18.43020203, 18.43248988])}, | |
{'hoverinfo': 'y', | |
'line': {'color': 'rgb(0, 152, 244)', 'width': 3}, | |
'name': '2017', | |
'type': 'scatter', | |
'x': RangeIndex(start=0, stop=153, step=1), | |
'y': array([ 3.50583492, 3.58147847, 3.67898858, 3.81073381, | |
3.94160848, 4.06897032, 4.21419261, 4.34126702, | |
4.4445688 , 4.55708755, 4.68080676, 4.79030137, | |
4.89398036, 5.00809306, 5.11591252, 5.21652377, | |
5.32421317, 5.43762835, 5.55892928, 5.68341331, | |
5.82567781, 5.96384359, 6.10787864, 6.23412912, | |
6.35249082, 6.46837886, 6.59174084, 6.70520369, | |
6.82022292, 6.93217899, 7.02335422, 7.12187843, | |
7.23622722, 7.34686329, 7.46031945, 7.58727543, | |
7.71091437, 7.82896437, 7.94994773, 8.0778104 , | |
8.21025222, 8.33580457, 8.462155 , 8.60271454, | |
8.74917417, 8.88537575, 9.02111537, 9.15853851, | |
9.27251088, 9.36770486, 9.45015858, 9.52209777, | |
9.59298639, 9.67847292, 9.76868861, 9.86539724, | |
9.97230033, 10.07439886, 10.16168812, 10.25344843, | |
10.361679 , 10.47362889, 10.58152739, 10.71362905, | |
10.85802866, 11.00149679, 11.14252453, 11.29462666, | |
11.44479836, 11.59150799, 11.72315653, 11.84662577, | |
11.94400108, 12.02291798, 12.09464483, 12.1903259 , | |
12.29032067, 12.40792287, 12.51970561, 12.61130836, | |
12.68795011, 12.76568501, 12.83149227, 12.92186373, | |
13.02187907, 13.11621133, 13.2006593 , 13.28295076, | |
13.35523399, 13.44511551, 13.53008823, 13.62365922, | |
13.74068565, 13.86323202, 13.97802764, 14.09544329, | |
14.21396085, 14.32773938, 14.4230887 , 14.49743297, | |
14.57345012, 14.64290923, 14.70053438, 14.76648623, | |
14.8311905 , 14.88246474, 14.93413104, 14.9926483 , | |
15.06755208, np.nan, np.nan, np.nan, | |
np.nan, np.nan, np.nan, np.nan, | |
np.nan, np.nan, np.nan, np.nan, | |
np.nan, np.nan, np.nan, np.nan, | |
np.nan, np.nan, np.nan, np.nan, | |
np.nan, np.nan, np.nan, np.nan, | |
np.nan, np.nan, np.nan, np.nan, | |
np.nan, np.nan, np.nan, np.nan, | |
np.nan, np.nan, np.nan, np.nan, | |
np.nan, np.nan, np.nan, np.nan, | |
np.nan, np.nan, np.nan, np.nan, np.nan])}] | |
layout = go.Layout({'annotations': [{'font': {'size': 22}, | |
'showarrow': False, | |
'text': 'Apr', | |
'x': 14, | |
'y': -0.05, | |
'yanchor': 'bottom', | |
'yref': 'paper'}, | |
{'font': {'size': 22}, | |
'showarrow': False, | |
'text': 'May', | |
'x': 44, | |
'y': -0.05, | |
'yanchor': 'bottom', | |
'yref': 'paper'}, | |
{'font': {'size': 22}, | |
'showarrow': False, | |
'text': 'Jun', | |
'x': 75, | |
'y': -0.05, | |
'yanchor': 'bottom', | |
'yref': 'paper'}, | |
{'font': {'size': 22}, | |
'showarrow': False, | |
'text': 'Jul', | |
'x': 105, | |
'y': -0.05, | |
'yanchor': 'bottom', | |
'yref': 'paper'}, | |
{'font': {'size': 22}, | |
'showarrow': False, | |
'text': 'Aug', | |
'x': 136, | |
'y': -0.05, | |
'yanchor': 'bottom', | |
'yref': 'paper'}, | |
{'font': {'size': 16}, | |
'showarrow': False, | |
'text': 'National Snow and Ice Data Center, ' | |
'University of Colorado Boulder', | |
'textangle': 270, | |
'x': 1.03, | |
'xref': 'paper', | |
'y': 0, | |
'yref': 'paper'}, | |
{'font': {'size': 14}, | |
'showarrow': False, | |
'text': '18 Jul 2017', | |
'x': 1, | |
'xref': 'paper', | |
'y': -0.08, | |
'yref': 'paper'}], | |
'font': {'color': 'rgba(0, 0, 0, 1)'}, | |
'height': 840, | |
'legend': {'bgcolor': 'rgba(0, 0, 0, 0)', | |
'font': {'size': 22}, | |
'x': 1, | |
'xanchor': 'right', | |
'y': 0, | |
'yanchor': 'bottom'}, | |
'margin': {'b': 84, 'l': 100, 'r': 110, 't': 126}, | |
'showlegend': True, | |
'title': 'Antarctic Sea Ice Extent<br>(Area of ocean with at least ' | |
'15% sea ice)', | |
'titlefont': {'size': 35}, | |
'width': 1050, | |
'xaxis': {'showline': True, | |
'showticklabels': False, | |
'ticks': 'inside', | |
'tickvals': [0, 30, 61, 91, 122], | |
'zeroline': False}, | |
'yaxis': {'range': [2, 19], | |
'showline': True, | |
'tickfont': {'size': 22}, | |
'title': 'Extent (millions of square kilometers)', | |
'titlefont': {'size': 28}}}) | |
layout2 = go.Layout(title='A Simple Plot', width=800, height=640) | |
fig = go.Figure(data=data, layout=layout2) | |
py.image.save_as(fig, filename='a-simple-plot.png') | |
print("saved a-simple-plot.png") | |
fig2 = go.Figure(data=data, layout=layout) | |
py.image.save_as(fig2, filename='a-simple-plot-complex-layout.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment