Polyglot programming

Python 2

Interactive widgets

For more examples

%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from IPython.html.widgets import interactive
from IPython.display import display
:0: FutureWarning: IPython widgets are experimental and may change in the future.
from scipy.stats import beta
plt.style.use('ggplot')

def dist(a=1, b=1):
    x = np.linspace(0, 1, 100)
    pdf = beta.pdf(x, a, b)
    plt.plot(pdf)
    return pdf

widget = interactive(dist, a=(0.0, 5.0), b=(0.0, 5.0))
widget.background_color = 'lightsalmon'
display(widget)
_images/MultiKernel_4_0.png
widget.close()
# Currnet settings of variables
widget.kwargs
{'a': 0.8, 'b': 0.7}
# Current value of function
pdf = widget.result
plt.plot(pdf);
_images/MultiKernel_7_0.png

Bokeh

More examples

from bokeh.plotting import *
from bokeh.models import ColumnDataSource