Skip to content

Instantly share code, notes, and snippets.

@julian-west
Created September 7, 2019 17:09
Show Gist options
  • Save julian-west/ca80206a4d1010b40a3cbf0382279ec1 to your computer and use it in GitHub Desktop.
Save julian-west/ca80206a4d1010b40a3cbf0382279ec1 to your computer and use it in GitHub Desktop.
# ---------------------------------------
# Plot graph
# ---------------------------------------
# edges
tracer = go.Scatter(x=Xedges, y=Yedges,
mode='lines',
line= dict(color='#DCDCDC', width=1),
hoverinfo='none',
showlegend=False)
# nodes
tracer_marker = go.Scatter(x=Xnodes, y=Ynodes,
mode='markers+text',
textposition='top center',
marker=dict(size=node_size,
line=dict(width=1),
color=node_colour),
hoverinfo='text',
hovertext=description,
text=node_label,
textfont=dict(size=7),
showlegend=False)
axis_style = dict(title='',
titlefont=dict(size=20),
showgrid=False,
zeroline=False,
showline=False,
ticks='',
showticklabels=False)
layout = dict(title='Plotly - interactive minimum spanning tree',
width=800,
height=800,
autosize=False,
showlegend=False,
xaxis=axis_style,
yaxis=axis_style,
hovermode='closest',
plot_bgcolor = '#fff')
fig = dict(data=[tracer, tracer_marker], layout=layout)
display(HTML("""<p>Node sizes are proportional to the size of annualised returns.<br>
Node colours signify positive or negative returns since beginning of the timeframe.</p> """))
iplot(fig)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment