Guest User

Untitled

a guest
Oct 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. import plotly
  2. import pandas as pd
  3. import numpy as np
  4. import urllib, json
  5. import plotly.graph_objs as go
  6.  
  7. plotly.offline.init_notebook_mode(connected=True)
  8.  
  9. trees_df = pd.read_csv('trees.csv', encoding='cp1252')
  10.  
  11. trees_df.head()
  12.  
  13. data_trace = dict(type='sankey', domain=dict(x=[0,1],y=[0,1]),
  14. orientation="h", valueformat=".0f",
  15. node = dict(pad=10, thickness=50,
  16. line = dict(color="black",width=0.5),
  17. label=trees_df['node_label'].dropna(axis=0, how='any'),
  18. color=trees_df['node_color']),
  19. link = dict(source=trees_df['source'].dropna(axis=0, how='any'),
  20. target=trees_df['target'].dropna(axis=0, how='any'),
  21. value=trees_df['value'].dropna(axis=0, how='any'),
  22. color=trees_df['trace_color'].dropna(axis=0, how='any')))
  23.  
  24. layout = dict(title="Native Tree Species of Canada",
  25. font=dict(size=11))
  26.  
  27. fig = dict(data=[data_trace], layout=layout)
  28. plotly.offline.iplot(fig, validate=False)
Add Comment
Please, Sign In to add comment