commit d9bfe376ecc6d9333157a58c89d1f89a2a0722ae Author: Carmen Li Date: Wed Sep 30 12:58:35 2020 +0100 initial commit diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..65d7760 --- /dev/null +++ b/readme.md @@ -0,0 +1,5 @@ +Useful code for the sector coupling project. +Included in this repository: +1, Sankey diagram generation from CSV files. +Quick change of the positions of nodes and values of links directly in the CSV files. +Commands for generating links and nodes automatically, as well as for propagating colours from nodes to links will be uploaded later. diff --git a/sankey/links_energy_only.csv b/sankey/links_energy_only.csv new file mode 100644 index 0000000..d6474fd --- /dev/null +++ b/sankey/links_energy_only.csv @@ -0,0 +1,62 @@ +,Source,Target,Label,Value,Colour,Source_code,Target_code +0,Biomass,ST Biomass CCS,,-1251736,"rgba(101, 123, 71, 0.8)",0,26 +1,ST Biomass CCS,Electricity,,400555,"rgba(58, 78, 9, 0.8)",26,8 +2,ST Biomass CCS,Losses,,-851181,"rgba(127, 127, 127, 0.8)",26,18 +3,Biomass,Buildings,,-37738,"rgba(101, 123, 71, 0.8)",0,2 +4,Biomass,Industry,,-290750,"rgba(101, 123, 71, 0.8)",0,17 +5,Biomass,Transport others,,-188907,"rgba(101, 123, 71, 0.8)",0,28 +6,Biomethane,CCGT advanced,,-90892,"rgba(137, 183, 21, 0.8)",1,3 +7,CCGT advanced,Electricity,,59891,"rgba(82, 76, 5, 0.8)",3,8 +8,CCGT advanced,Losses,,-35175,"rgba(127, 127, 127, 0.8)",3,18 +9,Biomethane,Buildings,,-710507,"rgba(137, 183, 21, 0.8)",1,2 +10,Biomethane,Industry,,-116300,"rgba(137, 183, 21, 0.8)",1,17 +11,Biomethane,Cars,,-113873,"rgba(137, 183, 21, 0.8)",1,4 +12,Biomethane,HGV,,-117620,"rgba(137, 183, 21, 0.8)",1,15 +13,Biomethane,Transport others,,-808,"rgba(137, 183, 21, 0.8)",1,28 +14,Natural gas,NG ATR CCS,,-708026,"rgba(99, 47, 18, 0.8)",20,19 +15,NG ATR CCS,H2,,517563,"rgba(245, 228, 0, 0.8)",19,12 +16,NG ATR CCS,Losses,,-190463,"rgba(127, 127, 127, 0.8)",19,18 +17,Natural gas,Buildings,,-152122,"rgba(99, 47, 18, 0.8)",20,2 +18,Natural gas,Industry,,-46520,"rgba(99, 47, 18, 0.8)",20,17 +19,Diesel,Transport others,,-290085,"rgba(46, 29, 25, 0.8)",5,28 +20,Uranium,Nuclear generation,,-2064570,"rgba(148, 103, 189, 0.8)",30,21 +21,Nuclear generation,Electricity,,784536,"rgba(148, 103, 189, 0.8)",21,8 +22,Nuclear generation,Losses,,-1280034,"rgba(127, 127, 127, 0.8)",21,18 +23,Gasoline,Cars,,-45200,"rgba(140, 86, 75, 0.8)",10,4 +24,E-gas,CCGT advanced,,-4174,"rgba(0, 163, 109, 0.8)",6,3 +25,H2,H2 methanation egas,,-768658,"rgba(245, 228, 0, 0.8)",12,13 +26,H2 methanation egas,E-gas,,614927,"rgba(0, 163, 109, 0.8)",13,6 +27,H2 methanation egas,Losses,,-153731,"rgba(127, 127, 127, 0.8)",13,18 +28,E-gas,Buildings,,-39947,"rgba(21, 93, 153, 0.8)",6,2 +29,E-gas,Industry,,-124441,"rgba(30, 84, 87, 0.8)",6,17 +30,E-gas,Cars,,-221353,"rgba(193, 153, 21, 0.8)",6,4 +31,E-gas,HGV,,-221280,"rgba(53, 53, 130, 0.8)",6,15 +32,E-gas,Transport others,,-3732,"rgba(81, 26, 80, 0.8)",6,28 +33,H2,H2 methanation eliquids,,-537000,"rgba(245, 228, 0, 0.8)",12,14 +34,H2 methanation eliquids,E-liquids,,429063,"rgba(182, 68, 197, 0.8)",14,7 +35,H2 methanation eliquids,Losses,,-107937,"rgba(127, 127, 127, 0.8)",14,18 +36,E-liquids,Buildings,,-169337,"rgba(21, 93, 153, 0.8)",7,2 +37,E-liquids,Transport others,,-259726,"rgba(81, 26, 80, 0.8)",7,28 +38,H2,Underground H2 store,,-1223,"rgba(153, 123, 15, 0.8)",12,29 +39,H2,Buildings,,-66292,"rgba(21, 93, 153, 0.8)",12,2 +40,H2,Industry,,-337270,"rgba(30, 84, 87, 0.8)",12,17 +41,H2,Public transport,,-11876,"rgba(255, 0, 255, 0.8)",12,24 +42,H2,HGV,,-504074,"rgba(53, 53, 130, 0.8)",12,15 +43,H2,Transport others,,-1493,"rgba(81, 26, 80, 0.8)",12,28 +44,Hydro ROR,Electricity,,189325,"rgba(0, 14, 209, 0.8)",16,8 +45,Tidal wave,Electricity,,23606,"rgba(26, 64, 81, 0.8)",27,8 +46,Geothermal,Electricity,,2394,"rgba(166, 47, 7, 0.8)",11,8 +47,Residential PV,Electricity,,503385,"rgba(255, 127, 14, 0.8)",25,8 +48,Utility PV,Electricity,,821757,"rgba(255, 59, 15, 0.8)",31,8 +49,Offshore wind,Electricity,,1359965,"rgba(26, 167, 255, 0.8)",22,8 +50,Onshore wind,Electricity,,2672225,"rgba(112, 199, 240, 0.8)",23,8 +51,Electricity,Electrolysis,,-2059564,"rgba(76, 7, 166, 0.8)",8,9 +52,Electrolysis,H2,,1710324,"rgba(245, 228, 0, 0.8)",9,12 +53,Electrolysis,Losses,,-349240,"rgba(127, 127, 127, 0.8)",9,18 +54,Electricity,Industry,,-1381400,"rgba(30, 84, 87, 0.8)",8,17 +55,Electricity,Buildings,,-2062526,"rgba(21, 93, 153, 0.8)",8,2 +56,Electricity,Cars,,-506593,"rgba(193, 153, 21, 0.8)",8,4 +57,Electricity,Public transport,,-35190,"rgba(255, 0, 255, 0.8)",8,24 +58,Electricity,HGV,,-59639,"rgba(53, 53, 130, 0.8)",8,15 +59,Electricity,Transport others,,-129372,"rgba(81, 26, 80, 0.8)",8,28 +60,Electricity,Losses,,583355,"rgba(127, 127, 127, 0.8)",8,18 diff --git a/sankey/nodes_energy_only.csv b/sankey/nodes_energy_only.csv new file mode 100644 index 0000000..93f78c9 --- /dev/null +++ b/sankey/nodes_energy_only.csv @@ -0,0 +1,33 @@ +node,type,x,y,color +Biomass,origin,0.1,0.625,"rgba(101, 123, 71, 0.8)" +Biomethane,origin,0.1,0.725,"rgba(137, 183, 21, 0.8)" +Buildings,consumption,0.95,0.1,"rgba(21, 93, 153, 0.8)" +CCGT advanced,generation,0.3,0.76,"rgba(82, 76, 5, 0.8)" +Cars,consumption,0.95,0.48,"rgba(193, 153, 21, 0.8)" +Diesel,origin,0.1,0.9,"rgba(46, 29, 25, 0.8)" +E-gas,synthetic,0.765,0.55,"rgba(0, 163, 109, 0.8)" +E-liquids,synthetic,0.765,0.61,"rgba(182, 68, 197, 0.8)" +Electricity,electricity,0.4,0.4,"rgba(255, 15, 15, 0.8)" +Electrolysis,electrolysis,0.475,0.65,"rgba(76, 7, 166, 0.8)" +Gasoline,origin,0.1,0.875,"rgba(140, 86, 75, 0.8)" +Geothermal,origin,0.1,0.42,"rgba(166, 47, 7, 0.8)" +H2,H2,0.545,0.79,"rgba(245, 228, 0, 0.8)" +H2 methanation egas,methanation,0.625,0.63,"rgba(0, 163, 109, 0.8)" +H2 methanation eliquids,methanation,0.625,0.68,"rgba(182, 68, 197, 0.8)" +HGV,consumption,0.95,0.7,"rgba(53, 53, 130, 0.8)" +Hydro ROR,origin,0.1,0.38,"rgba(0, 14, 209, 0.8)" +Industry,consumption,0.95,0.25,"rgba(30, 84, 87, 0.8)" +Losses,losses,0.7,1,"rgba(127, 127, 127, 0.8)" +NG ATR CCS,H2_production,0.3,0.8,"rgba(63, 20, 9, 0.8)" +Natural gas,origin,0.1,0.8,"rgba(99, 47, 18, 0.8)" +Nuclear generation,generation,0.225,0.5,"rgba(148, 103, 189, 0.8)" +Offshore wind,origin,0.1,0.1,"rgba(26, 167, 255, 0.8)" +Onshore wind,origin,0.1,0.2,"rgba(112, 199, 240, 0.8)" +Public transport,consumption,0.95,0.62,"rgba(255, 0, 255, 0.8)" +Residential PV,origin,0.1,0.35,"rgba(255, 127, 14, 0.8)" +ST Biomass CCS,generation,0.3,0.61,"rgba(58, 78, 9, 0.8)" +Tidal wave,origin,0.1,0.4,"rgba(26, 64, 81, 0.8)" +Transport others,consumption,0.95,0.825,"rgba(81, 26, 80, 0.8)" +Underground H2 store,store,0.95,0.95,"rgba(153, 123, 15, 0.8)" +Uranium,origin,0.1,0.5,"rgba(148, 103, 189, 0.8)" +Utility PV,origin,0.1,0.3,"rgba(255, 59, 15, 0.8)" diff --git a/sankey/sankey from csv.ipynb b/sankey/sankey from csv.ipynb new file mode 100644 index 0000000..7d9eb12 --- /dev/null +++ b/sankey/sankey from csv.ipynb @@ -0,0 +1,1405 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import plotly.graph_objects as go\n", + "import pandas as pd" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "arrangement": "fixed", + "link": { + "color": [ + "rgba(101, 123, 71, 0.8)", + "rgba(58, 78, 9, 0.8)", + "rgba(127, 127, 127, 0.8)", + "rgba(101, 123, 71, 0.8)", + "rgba(101, 123, 71, 0.8)", + "rgba(101, 123, 71, 0.8)", + "rgba(137, 183, 21, 0.8)", + "rgba(82, 76, 5, 0.8)", + "rgba(127, 127, 127, 0.8)", + "rgba(137, 183, 21, 0.8)", + "rgba(137, 183, 21, 0.8)", + "rgba(137, 183, 21, 0.8)", + "rgba(137, 183, 21, 0.8)", + "rgba(137, 183, 21, 0.8)", + "rgba(99, 47, 18, 0.8)", + "rgba(245, 228, 0, 0.8)", + "rgba(127, 127, 127, 0.8)", + "rgba(99, 47, 18, 0.8)", + "rgba(99, 47, 18, 0.8)", + "rgba(46, 29, 25, 0.8)", + "rgba(148, 103, 189, 0.8)", + "rgba(148, 103, 189, 0.8)", + "rgba(127, 127, 127, 0.8)", + "rgba(140, 86, 75, 0.8)", + "rgba(0, 163, 109, 0.8)", + "rgba(245, 228, 0, 0.8)", + "rgba(0, 163, 109, 0.8)", + "rgba(127, 127, 127, 0.8)", + "rgba(21, 93, 153, 0.8)", + "rgba(30, 84, 87, 0.8)", + "rgba(193, 153, 21, 0.8)", + "rgba(53, 53, 130, 0.8)", + "rgba(81, 26, 80, 0.8)", + "rgba(245, 228, 0, 0.8)", + "rgba(182, 68, 197, 0.8)", + "rgba(127, 127, 127, 0.8)", + "rgba(21, 93, 153, 0.8)", + "rgba(81, 26, 80, 0.8)", + "rgba(153, 123, 15, 0.8)", + "rgba(21, 93, 153, 0.8)", + "rgba(30, 84, 87, 0.8)", + "rgba(255, 0, 255, 0.8)", + "rgba(53, 53, 130, 0.8)", + "rgba(81, 26, 80, 0.8)", + "rgba(0, 14, 209, 0.8)", + "rgba(26, 64, 81, 0.8)", + "rgba(166, 47, 7, 0.8)", + "rgba(255, 127, 14, 0.8)", + "rgba(255, 59, 15, 0.8)", + "rgba(26, 167, 255, 0.8)", + "rgba(112, 199, 240, 0.8)", + "rgba(76, 7, 166, 0.8)", + "rgba(245, 228, 0, 0.8)", + "rgba(127, 127, 127, 0.8)", + "rgba(30, 84, 87, 0.8)", + "rgba(21, 93, 153, 0.8)", + "rgba(193, 153, 21, 0.8)", + "rgba(255, 0, 255, 0.8)", + "rgba(53, 53, 130, 0.8)", + "rgba(81, 26, 80, 0.8)", + "rgba(127, 127, 127, 0.8)" + ], + "label": [ + "-1251736 GWh", + "400555 GWh", + "-851181 GWh", + "-37738 GWh", + "-290750 GWh", + "-188907 GWh", + "-90892 GWh", + "59891 GWh", + "-35175 GWh", + "-710507 GWh", + "-116300 GWh", + "-113873 GWh", + "-117620 GWh", + "-808 GWh", + "-708026 GWh", + "517563 GWh", + "-190463 GWh", + "-152122 GWh", + "-46520 GWh", + "-290085 GWh", + "-2064570 GWh", + "784536 GWh", + "-1280034 GWh", + "-45200 GWh", + "-4174 GWh", + "-768658 GWh", + "614927 GWh", + "-153731 GWh", + "-39947 GWh", + "-124441 GWh", + "-221353 GWh", + "-221280 GWh", + "-3732 GWh", + "-537000 GWh", + "429063 GWh", + "-107937 GWh", + "-169337 GWh", + "-259726 GWh", + "-1223 GWh", + "-66292 GWh", + "-337270 GWh", + "-11876 GWh", + "-504074 GWh", + "-1493 GWh", + "189325 GWh", + "23606 GWh", + "2394 GWh", + "503385 GWh", + "821757 GWh", + "1359965 GWh", + "2672225 GWh", + "-2059564 GWh", + "1710324 GWh", + "-349240 GWh", + "-1381400 GWh", + "-2062526 GWh", + "-506593 GWh", + "-35190 GWh", + "-59639 GWh", + "-129372 GWh", + "583355 GWh" + ], + "source": [ + 0, + 26, + 26, + 0, + 0, + 0, + 1, + 3, + 3, + 1, + 1, + 1, + 1, + 1, + 20, + 19, + 19, + 20, + 20, + 5, + 30, + 21, + 21, + 10, + 6, + 12, + 13, + 13, + 6, + 6, + 6, + 6, + 6, + 12, + 14, + 14, + 7, + 7, + 12, + 12, + 12, + 12, + 12, + 12, + 16, + 27, + 11, + 25, + 31, + 22, + 23, + 8, + 9, + 9, + 8, + 8, + 8, + 8, + 8, + 8, + 8 + ], + "target": [ + 26, + 8, + 18, + 2, + 17, + 28, + 3, + 8, + 18, + 2, + 17, + 4, + 15, + 28, + 19, + 12, + 18, + 2, + 17, + 28, + 21, + 8, + 18, + 4, + 3, + 13, + 6, + 18, + 2, + 17, + 4, + 15, + 28, + 14, + 7, + 18, + 2, + 28, + 29, + 2, + 17, + 24, + 15, + 28, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 9, + 12, + 18, + 17, + 2, + 4, + 24, + 15, + 28, + 18 + ], + "value": [ + 1251736, + 400555, + 851181, + 37738, + 290750, + 188907, + 90892, + 59891, + 35175, + 710507, + 116300, + 113873, + 117620, + 808, + 708026, + 517563, + 190463, + 152122, + 46520, + 290085, + 2064570, + 784536, + 1280034, + 45200, + 4174, + 768658, + 614927, + 153731, + 39947, + 124441, + 221353, + 221280, + 3732, + 537000, + 429063, + 107937, + 169337, + 259726, + 1223, + 66292, + 337270, + 11876, + 504074, + 1493, + 189325, + 23606, + 2394, + 503385, + 821757, + 1359965, + 2672225, + 2059564, + 1710324, + 349240, + 1381400, + 2062526, + 506593, + 35190, + 59639, + 129372, + 583355 + ] + }, + "node": { + "color": [ + "rgba(101, 123, 71, 0.8)", + "rgba(137, 183, 21, 0.8)", + "rgba(21, 93, 153, 0.8)", + "rgba(82, 76, 5, 0.8)", + "rgba(193, 153, 21, 0.8)", + "rgba(46, 29, 25, 0.8)", + "rgba(0, 163, 109, 0.8)", + "rgba(182, 68, 197, 0.8)", + "rgba(255, 15, 15, 0.8)", + "rgba(76, 7, 166, 0.8)", + "rgba(140, 86, 75, 0.8)", + "rgba(166, 47, 7, 0.8)", + "rgba(245, 228, 0, 0.8)", + "rgba(0, 163, 109, 0.8)", + "rgba(182, 68, 197, 0.8)", + "rgba(53, 53, 130, 0.8)", + "rgba(0, 14, 209, 0.8)", + "rgba(30, 84, 87, 0.8)", + "rgba(127, 127, 127, 0.8)", + "rgba(63, 20, 9, 0.8)", + "rgba(99, 47, 18, 0.8)", + "rgba(148, 103, 189, 0.8)", + "rgba(26, 167, 255, 0.8)", + "rgba(112, 199, 240, 0.8)", + "rgba(255, 0, 255, 0.8)", + "rgba(255, 127, 14, 0.8)", + "rgba(58, 78, 9, 0.8)", + "rgba(26, 64, 81, 0.8)", + "rgba(81, 26, 80, 0.8)", + "rgba(153, 123, 15, 0.8)", + "rgba(148, 103, 189, 0.8)", + "rgba(255, 59, 15, 0.8)" + ], + "label": [ + "Biomass", + "Biomethane", + "Buildings", + "CCGT advanced", + "Cars", + "Diesel", + "E-gas", + "E-liquids", + "Electricity", + "Electrolysis", + "Gasoline", + "Geothermal", + "H2", + "H2 methanation egas", + "H2 methanation eliquids", + "HGV", + "Hydro ROR", + "Industry", + "Losses", + "NG ATR CCS", + "Natural gas", + "Nuclear generation", + "Offshore wind", + "Onshore wind", + "Public transport", + "Residential PV", + "ST Biomass CCS", + "Tidal wave", + "Transport others", + "Underground H2 store", + "Uranium", + "Utility PV" + ], + "line": { + "color": "black", + "width": 1 + }, + "pad": 15, + "thickness": 25, + "x": [ + 0.1, + 0.1, + 0.95, + 0.3, + 0.95, + 0.1, + 0.765, + 0.765, + 0.4, + 0.475, + 0.1, + 0.1, + 0.545, + 0.625, + 0.625, + 0.95, + 0.1, + 0.95, + 0.7, + 0.3, + 0.1, + 0.225, + 0.1, + 0.1, + 0.95, + 0.1, + 0.3, + 0.1, + 0.95, + 0.95, + 0.1, + 0.1 + ], + "y": [ + 0.625, + 0.725, + 0.1, + 0.76, + 0.48, + 0.9, + 0.55, + 0.61, + 0.4, + 0.65, + 0.875, + 0.42, + 0.79, + 0.63, + 0.68, + 0.7, + 0.38, + 0.25, + 1, + 0.8, + 0.8, + 0.5, + 0.1, + 0.2, + 0.62, + 0.35, + 0.61, + 0.4, + 0.825, + 0.95, + 0.5, + 0.3 + ] + }, + "type": "sankey", + "valueformat": ".0f", + "valuesuffix": "GWh" + } + ], + "layout": { + "font": { + "size": 24 + }, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "All countries" + } + } + }, + "text/html": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "df_nodes=pd.read_csv('nodes_energy_only.csv')\n", + "df_links=pd.read_csv('links_energy_only.csv')\n", + "\n", + "opacity = 0.4\n", + "\n", + "fig = go.Figure(data=[go.Sankey(\n", + " arrangement='fixed',\n", + " valueformat = \".0f\",\n", + " valuesuffix = \"GWh\",\n", + " # Define nodes\n", + " node = dict(\n", + " pad = 15,\n", + " thickness = 25,\n", + " line = dict(color = \"black\", width = 1),\n", + " label = df_nodes['node'].values,\n", + " x=df_nodes['x'].values,\n", + " y=df_nodes['y'].values,\n", + " color=df_nodes['color'].values\n", + " \n", + " \n", + " ),\n", + " # Add links\n", + " link = dict(\n", + " source = df_links['Source_code'].values,\n", + " target = df_links['Target_code'].values,\n", + " value = abs(df_links['Value'].values),\n", + " label = ['%d GWh' %val for val in df_links['Value'].values],\n", + " color = df_links['Colour'].values\n", + "))])\n", + "\n", + "fig.update_layout(title_text='All countries', font_size=24)\n", + "fig.write_html(\"all_countries.html\")\n", + "fig.write_image(\"all_countries.png\", width=2500, height=1200)\n", + "fig.show()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.2" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +}