In [18]:
import pandas as pd
import numpy as np
import plotly.graph_objs as go
In [19]:
#read excel files in to pandas dataframe
file_nodes = r'D:\Python Scripts\Sankey_Power_Generation\nodes.xlsx'
In [20]:
df_nodes = pd.read_excel(file_nodes)
All values are in MW. Source of data is Wikipedia. Data is as of 31st March 2019.
In [21]:
df_nodes
Out[21]:
In [22]:
#read excel files in to pandas dataframe
file_links = r'D:\Python Scripts\Sankey_Power_Generation\link.xlsx'
In [23]:
df_links = pd.read_excel(file_links)
In [24]:
df_links
Out[24]:
In [ ]:
fig = go.Figure(data=[go.Sankey(node=dict(
pad=15,
thickness=20,
line=dict(color="black",width=0.5),
label=df_nodes['Label'].dropna(axis=0, how='any'),
color=df_nodes['Colour']),link=dict(
source=df_links['Source'].dropna(axis=0, how='any'),
target=df_links['Target'].dropna(axis=0, how='any'),
value=df_links['Value'].dropna(axis=0, how='any'),
color=df_links['LinkColour'].dropna(axis=0, how='any'),
))])
# print(fig)
fig.update_layout(title_text="Basic Sankey Diagram", font_size=10)
fig.show()
No comments:
Post a Comment