I have been trying to make a sankey diagram for an assignment. I found an amazing code at: https://plot.ly/~alishobeiri/1591/plotly-sankey-diagrams/ which I am using and adapting to my requirements. However I am getting the error:
SyntaxError: unexpected EOF while parsing
for all dict ()
.
Data: https://drive.google.com/open?id=0BzIHBf19BxTbUktNcG1uSWtUOEE
Code:
import json, urllib
import plotly.plotly as py
import pandas as pd
import numpy as np
land_change = pd.read_csv(r'test.csv')
land_change.head()
data_trace = dict(
type = 'sankey',
domain = dict(
x = [0,1],
y = [0,1]),
orientation = "h",
valueformat = ".0f",
node = dict(
pad = 10,
thickness = 30,
line = dict(
color = "black",
width = 0.5),
label = land_change['Node, Label'].dropna(axis=0, how='any'),
color = land_change['Color']),
link = dict(
source = land_change['Source'].dropna(axis=0, how='any'),
target = land_change['Target'].dropna(axis=0, how='any'),
value = land_change['Value'].dropna(axis=0, how='any'),))
layout = dict(
title = "Land cover and use change for period 1990 - 2000 & 2000 - 2014.",
height = 772,
width = 950,
font = dict(
size = 10
),
)
fig = dict(data=[data_trace], layout=layout)
py.iplot(fig, validate=False)