Skip to content

Instantly share code, notes, and snippets.

@jsierles
Last active August 14, 2017 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsierles/6032fa8f93592554f08f5893cafe833d to your computer and use it in GitHub Desktop.
Save jsierles/6032fa8f93592554f08f5893cafe833d to your computer and use it in GitHub Desktop.
# setting up the layout of matplotlib figure
fig, ax = plt.subplots()
# use the distplot function from seaborn to plot the distribution of AAPL
sns.distplot(AAPL['Daily Return'].dropna(), color = 'indianred',
hist_kws=dict(alpha = 0.7))
# remove the plot borders
sns.despine()
#get the plotly json object
fig = plotly.tools.mpl_to_plotly(fig)
# polish the histogram plot
fig['data'][1]['marker']['line']['color'] = 'white'
fig['data'][1]['marker']['line']['width'] = 1
# controlling the size of the figure and adding title
fig['layout'].update(title = "AAPL Daily Return Distribution",
width = 850, height = 450,
xaxis = dict(showgrid=False))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment