I am trying to plot a bar chart in offline mode in Jupyter Ipython notebook. I am trying to reproduce the bar chart in the second example of this page: https://plot.ly/matplotlib/bar-charts/
Here is my code:
import plotly
import datetime
import matplotlib.pyplot as plt
%matplotlib inline
#Here I changed my personal username and API_key with the one provided on
#plotly's "getting started page", though I believe I should not need to sign in
#in offline mode
plotly.plotly.sign_in('DemoAccount', 'lr1c37zw81')
#Here is the matplotlib figure I would like to load in plotly
date = plt.figure()
x = [datetime.datetime(2010, 12, 1, 10, 0),
datetime.datetime(2011, 1, 4, 9, 0),
datetime.datetime(2011, 5, 5, 9, 0)]
y = [4, 9, 2]
ax = plt.subplot(111)
ax.bar(x, y, width=10)
ax.xaxis_date()
plt.show()
plotly.offline.init_notebook_mode()
plotly.plotly.plot_mpl(date)
However, this code fails to load the picture inside the Ipython notebook (the chart is loaded in a new tab).
Can you help me out?
PS: I am using Python 3.4.3 and Plotly 1.9.0 .