Nuclear → Thermal generation 840 TWhThermal generation → Losses 787 TWhOil → Liquid 612 TWhThermal generation → Electricity grid 526 TWhOil imports → Oil 504 TWhSolid → Thermal generation 400 TWhElectricity grid → Industry 342 TWhWind → Electricity grid 289 TWhBio-conversion → Solid 280 TWhLiquid → International aviation 206 TWhPumped heat → Heating and cooling - homes 193 TWhUK land based bioenergy → Bio-conversion 182 TWhGas → Thermal generation 152 TWhLiquid → Road transport 136 TWhLiquid → International shipping 129 TWhAgricultural 'waste' → Bio-conversion 125 TWhNgas → Gas 123 TWhLiquid → Industry 121 TWhElectricity grid → Heating and cooling - homes 114 TWhOil reserves → Oil 108 TWhElectricity grid → Over generation / exports 104 TWhElectricity grid → Lighting & appliances - homes 93 TWhElectricity grid → Lighting & appliances - commercial 90 TWhGas reserves → Ngas 82 TWhBio-conversion → Gas 81 TWhThermal generation → District heating 79 TWhOther waste → Bio-conversion 78 TWhCoal → Solid 76 TWhPumped heat → Heating and cooling - commercial 71 TWhCoal reserves → Coal 64 TWhSolar PV → Electricity grid 60 TWhSolar → Solar PV 60 TWhElectricity grid → Losses 57 TWhOther waste → Solid 57 TWhGas → Industry 49 TWhSolid → Industry 46 TWhDistrict heating → Heating and cooling - homes 46 TWhElectricity grid → Heating and cooling - commercial 41 TWhGas imports → Ngas 41 TWhElectricity grid → Road transport 38 TWhBiofuel imports → Liquid 35 TWhBiomass imports → Solid 35 TWhLiquid → National navigation 33 TWhElectricity grid → H2 conversion 27 TWhBio-conversion → Losses 27 TWhDistrict heating → Heating and cooling - commercial 23 TWhH2 conversion → H2 21 TWhH2 → Road transport 21 TWhSolar Thermal → Heating and cooling - homes 19 TWhSolar → Solar Thermal 19 TWhWave → Electricity grid 19 TWhLiquid → Domestic aviation 14 TWhCoal imports → Coal 12 TWhDistrict heating → Industry 11 TWhTidal → Electricity grid 9 TWhElectricity grid → Rail transport 8 TWhGeothermal → Electricity grid 7 TWhHydro → Electricity grid 7 TWhH2 conversion → Losses 6 TWhLiquid → Rail transport 4 TWhElectricity grid → Agriculture 4 TWhMarine algae → Bio-conversion 4 TWhLiquid → Agriculture 4 TWhGas → Agriculture 2 TWhGas → Losses 1 TWhSolid → Agriculture 1 TWhBio-conversion → Liquid 1 TWhGas → Heating and cooling - commercial 0 TWhAgricultural 'waste' 125 TWhAgricultural 'waste'Bio-conversion 389 TWhBio-conversionLiquid 648 TWhLiquidLosses 878 TWhLossesSolid 447 TWhSolidGas 204 TWhGasBiofuel imports 35 TWhBiofuel importsBiomass imports 35 TWhBiomass importsCoal imports 12 TWhCoal importsCoal 76 TWhCoalCoal reserves 64 TWhCoal reservesDistrict heating 79 TWhDistrict heatingIndustry 569 TWhIndustryHeating and cooling - commercial 134 TWhHeating and cooling - commercialHeating and cooling - homes 372 TWhHeating and cooling - homesElectricity grid 919 TWhElectricity gridOver generation / exports 104 TWhOver generation / exportsH2 conversion 27 TWhH2 conversionRoad transport 195 TWhRoad transportAgriculture 11 TWhAgricultureRail transport 12 TWhRail transportLighting & appliances - commercial 90 TWhLighting & appliances - commercialLighting & appliances - homes 93 TWhLighting & appliances - homesGas imports 41 TWhGas importsNgas 123 TWhNgasGas reserves 82 TWhGas reservesThermal generation 1,392 TWhThermal generationGeothermal 7 TWhGeothermalH2 21 TWhH2Hydro 7 TWhHydroInternational shipping 129 TWhInternational shippingDomestic aviation 14 TWhDomestic aviationInternational aviation 206 TWhInternational aviationNational navigation 33 TWhNational navigationMarine algae 4 TWhMarine algaeNuclear 840 TWhNuclearOil imports 504 TWhOil importsOil 612 TWhOilOil reserves 108 TWhOil reservesOther waste 134 TWhOther wastePumped heat 264 TWhPumped heatSolar PV 60 TWhSolar PVSolar Thermal 19 TWhSolar ThermalSolar 79 TWhSolarTidal 9 TWhTidalUK land based bioenergy 182 TWhUK land based bioenergyWave 19 TWhWaveWind 289 TWhWind

  1. require(rCharts)
  2. require(rjson)
  3. #get source from original example
  4. #this is a JSON, so will need to translate
  5. #this is complicated and unnecessary but feel I need to replicate
  6. #for completeness
  7. #expect most data to come straight from R
  8. #in form of source, target, value
  9. links <- matrix(unlist(
  10. rjson::fromJSON(
  11. file = "//bost.ocks.org/mike/sankey/energy.json"
  12. )$links
  13. ),ncol = 3, byrow = TRUE)
  14. nodes <- unlist(
  15. rjson::fromJSON(
  16. file = "//bost.ocks.org/mike/sankey/energy.json"
  17. )$nodes
  18. )
  19. #convert to data.frame so souce and target can be character and value numeric
  20. links <- data.frame(links)
  21. colnames(links) <- c("source", "target", "value")
  22. links$source <- sapply(links$source, FUN = function(x) {return(as.character(nodes[x+1]))}) #x+1 since js starts at 0
  23. links$target <- sapply(links$target, FUN = function(x) {return(nodes[x+1])}) #x+1 since js starts at 0
  24. #now we finally have the data in the form we need
  25. sankeyPlot <- rCharts$new()
  26. sankeyPlot$setLib('.')
  27. sankeyPlot$setTemplate(script = "layouts/chart.html")
  28. sankeyPlot$set(
  29. data = links,
  30. nodeWidth = 15,
  31. nodePadding = 10,
  32. layout = 32,
  33. width = 960,
  34. height = 500,
  35. units = "TWh",
  36. title = "Sankey Diagram"
  37. )
  38. sankeyPlot