In order to cite ipynb
files, we need to install the liquid_tags plugin. Afterwards we can insert an ipynb doc to a Pelican post with the following line:
{% notebook ipynb/pelican_ipynb_mpld3_integration.ipynb %}
Then regenerate the HTML with make html
command.
Example
The following is an example ipynb
which reads the IBM stock and then plot out the closing price and its volume.
Notice the diagram shown below can be zoomed in/out
- You will need to hover the mouse on the diagram to see the hourglass for zooming
Rendered example notebook (shown below)
Test code for integrating with Pelican¶
- Read IBM stock price since 2000
- Use mpld3 to have dynamic diagrams
In [1]:
%matplotlib inline
import matplotlib.pylab as plt
import mpld3
mpld3.enable_notebook()
import pandas_datareader.data as web
In [2]:
f = web.DataReader("IBM", 'yahoo', '2000/01/01')
In [3]:
fig,ax = plt.subplots(2,1,figsize=(12,6),sharex=True)
[a.grid() for a in ax]
ax[0].plot(f['Close'].index,f['Close'].values)
ax[1].plot(f['Volume'].index,f['Volume'].values/1e6,'r-')
ax[0].set_ylabel('IBM Price (Closed)')
ax[1].set_ylabel('IBM Volume (Million)')
ax[0].set_title('IBM')
pass
Comments
comments powered by Disqus