Examples


nbpresent Examples

Here are some examples of using nbpresent with rich third-party libraries like Bokeh, qgrid and ipywidgets.


In [15]:
from bokeh.sampledata.iris import flowers
from bokeh.plotting import figure, show, output_notebook
output_notebook()


Loading BokehJS ...

In [16]:
colormap = {'setosa': 'red', 'versicolor': 'green', 'virginica': 'blue'}
flowers['color'] = flowers['species'].map(lambda x: colormap[x])

p = figure(title="Iris Morphology", width=1000, height=700)
p.xaxis.axis_label = 'Petal Length'
p.yaxis.axis_label = 'Petal Width'

p.circle(flowers["petal_length"], flowers["petal_width"],
        color=flowers["color"], fill_alpha=0.2, size=10, )

show(p);



In [17]:
from ipywidgets import widgets
import numpy as np  
import matplotlib.pyplot as plt
import pandas
import qgrid
qgrid.nbinstall(overwrite=True)
qgrid.set_defaults(remote_js=True, precision=4)


/Users/nbollweg/miniconda/envs/nbpresent/lib/python3.5/site-packages/IPython/html.py:14: ShimWarning: The `IPython.html` package has been deprecated. You should import from `notebook` instead. `IPython.html.widgets` has moved to `ipywidgets`.
  "`IPython.html.widgets` has moved to `ipywidgets`.", ShimWarning)

In [18]:
%matplotlib inline

In [19]:
@widgets.interact
def graph(a=10.0, b=2.0):
    x = np.array(range(-100, 100))/100
    y = np.sin((a * x)**b)
    plt.figure(figsize=(16,9))
    plt.plot(x, y)
    plt.show()



In [20]:
df = pandas.DataFrame(
    np.random.randn(100, 3)
)

In [21]:
qgrid.show_grid(df)



In [22]:
qgrid.show_grid(df.describe())