Example notebook for hosting on mybinder.org

June 15, 2020 7:53 PM EST
On Github datasciY repo.

MyBinder build environment

to add mybinder badge

environment.yml has to be at root level.
Re-built image, launch takes very long time.
-

In [1]:
# Add Opin in Binder badge.  

Used html table to make into a box.
To add black outline around table somehow.

In [1]:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits import mplot3d
%matplotlib inline

1. Matplotlib 3D plots

In [2]:
# 3D data  
def f(x, y):
    return np.cos(np.sqrt(x**2 + y**2))

x = np.linspace(-4, 4, 36)
y = np.linspace(-4, 4, 36)
X, Y = np.meshgrid(x, y)
Z = f(X, Y)
In [3]:
# OO Style, set plot
fig = plt.figure()
ax = plt.axes(projection='3d')
ax.contour3D(X, Y, Z, 60, cmap='RdBu')
ax.set(xlabel='X', ylabel='Y', zlabel='Z', title='Contour Plot 3D')
Out[3]:
[Text(0.5, 0, 'Z'),
 Text(0.5, 0, 'Y'),
 Text(0.5, 0, 'X'),
 Text(0.5, 0.92, 'Contour Plot 3D')]

2. Overploting Histograms

In [4]:
# data for 3 histograms, randomly generated  
x1 = np.random.normal(0, 0.5, 200)
x2 = np.random.normal(-2, 1, 200)
x3 = np.random.normal(3, 1.6, 200)
In [5]:
plt.style.use('seaborn-whitegrid')
kwargs = dict(histtype='stepfilled', alpha=0.4, density=True, bins=25)
plt.hist(x1, **kwargs)
plt.hist(x2, **kwargs)
plt.hist(x3, **kwargs)
plt.title('Three Histograms')
plt.xlabel('X data')
plt.ylabel('Y count');
In [6]:
!python --version
import datetime as dt
print(dt.date.today())
print(dt.datetime.now())
Python 3.8.3
2020-06-15
2020-06-15 23:53:43.306796
In [ ]: