Using ipywidgets_static in Python 3

In [1]:
import numpy as np
from matplotlib import pyplot as plt
from ipywidgets_static.interact import StaticInteract
from ipywidgets_static.widgets import RangeWidget, DropDownWidget, RadioWidget

def plot_example(fluxUpperBound, title, color):
    
    plt.rcParams.update({'figure.max_open_warning': 0})
    fig = plt.figure(figsize=(10,8))
    plt.title(title, fontsize=18)
    plt.xlabel('$v_j$', fontsize=18)
    plt.ylabel('$v_i$', fontsize=18)
    x = np.linspace(0, 1000, 10)
    plt.vlines(fluxUpperBound, 1000, 0, colors='orange', linewidth=3)

    line1, = plt.plot(x, x, color='black', linestyle='--', label='$v_i=v_j$')
    line2, = plt.plot(x, 0.5*x + 200, color='blue', linewidth=3, label='$v_i=0.5v_j+200$')
    line3, = plt.plot(x, 2*x + 250, color='red', linewidth=3, label='$v_i=2v_j+250$')
    plt.ylim(0, 1000)
    plt.xlim(0, 1000)
    xfill = np.linspace(0, fluxUpperBound, 10)
    plt.fill_between(xfill, 0.5*xfill + 200, 2*xfill + 250, color=color)

    plt.legend(handles=[line1, line2, line3], loc=4, frameon=False)
    plt.text(300, 600, '$v_i>v_j$', fontsize=18)
    plt.text(600, 300, '$v_i<v_j$', fontsize=18)

    return fig
In [2]:
titles = ['A title', 'Another title']
colors = ['lightgrey', 'lightblue']

StaticInteract(plot_example, fluxUpperBound=RangeWidget(
    0, 1000, step=100, default=600, width=200, description='$v_{ub}$'),
               title=DropDownWidget(titles, description='Title'),
               color=RadioWidget(colors, labels=['grey', 'blue'])
              )
Out[2]:
color: grey: blue:
$v_{ub}$ =
Title: