mpld3
¶See the mpld3 github for more about mpl3d. See the seaborn docs for more about seaborn.
Last updated December 30, 2013
import numpy as np
from numpy.random import randn
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from mpld3 import display_d3
np.random.seed(0)
def sinplot(flip=1):
x = np.linspace(0, 14, 100)
for i in range(1, 7):
plt.plot(x, np.sin(x + i * .5) * (7 - i) * flip)
x1 = randn(80)
x2 = randn(80)
x3 = x1 * x2
y1 = .5 + 2 * x1 - x2 + 2.5 * x3 + 3 * randn(80)
y2 = .5 + 2 * x1 - x2 + 2.5 * randn(80)
y3 = y2 + randn(80)
g = np.random.choice(list("ABC"), 80)
y_logistic = 1 / (1 + np.exp(-y1))
y_flip = [np.random.binomial(1, p) for p in y_logistic]
df = pd.DataFrame(dict(x1=x1, x2=x2, x3=x3, y1=y1, y2=y2, y3=y3, y_flip=y_flip, g=g))
d = randn(100, 30)
sinplot()
sinplot()
display_d3()
sns.set(style="whitegrid")
sinplot()
sinplot()
display_d3()
sns.set(style="nogrid")
sinplot()
sinplot()
display_d3()
sns.set()
sns.lmplot("x1", "y2", df)
fig = plt.gcf()
display_d3(fig)
sns.lmplot("x1", "y2", df, col="g", size=3.5)
fig = plt.gcf()