import numpy as np
import matplotlib.pyplot as plt
import seaborn
%matplotlib inline
y = np.random.randn(1000)
plt.plot(y)
x = np.linspace(-10., 10., 1000)
y = np.sin(3 * x) * np.exp(-.1 * x**2)
plt.plot(x, y)
x = np.linspace(-5., 5., 100)
y = np.sin(3 * x) * np.exp(-.1 * x ** 2)
plt.plot(x, y, '--^',
lw=3, color='#fdbb84',
mfc='#2b8cbe', ms=8)
x = np.random.randn(100)
y = x + np.random.randn(100)
plt.scatter(x, y)
# Left panel.
plt.subplot(1, 2, 1)
x = np.linspace(-10., 10., 1000)
plt.plot(x, np.sin(x), '-r', label='sinus')
plt.plot(x, np.cos(x), ':g', lw=1, label='cosinus')
plt.xticks([-10, 0, 10])
plt.yticks([-1, 0, 1])
plt.ylim(-2, 2)
plt.xlabel("x axis")
plt.ylabel("y axis")
plt.title("Two plots")
plt.legend()
# Right panel.
plt.subplot(1, 2, 2, polar=True)
x = np.linspace(0, 2 * np.pi, 1000)
plt.plot(x, 1 + 2 * np.cos(6 * x))
plt.yticks([])
plt.xlim(-.1, 3.1)
plt.ylim(-.1, 3.1)
plt.xticks(np.linspace(0, 5 * np.pi / 3, 6))
plt.title("A polar plot")
plt.grid(color='k', linewidth=1, linestyle=':')
from ipywidgets import interact
x = np.linspace(-5., 5., 1000)
@interact
def plot_sin(a=(1, 10)):
plt.plot(x, np.sin(a*x))
plt.ylim(-1, 1)
%matplotlib qt
lines = plt.plot([0, 1], [0, 1], 'b')
lines
[<matplotlib.lines.Line2D at 0x7ffa434542e8>]
lines[0].set_color('r')
plt.draw()
df = seaborn.load_dataset("iris")
df.head(3)
sepal_length sepal_width petal_length petal_width species 0 5.1 3.5 1.4 0.2 setosa 1 4.9 3.0 1.4 0.2 setosa 2 4.7 3.2 1.3 0.2 setosa
seaborn.pairplot(df, hue="species", size=2.5)