Skip to content

Instantly share code, notes, and snippets.

@mohayonao
Created May 24, 2016 13:44
Show Gist options
  • Select an option

  • Save mohayonao/30c4135107a32da8038080b21ce4f738 to your computer and use it in GitHub Desktop.

Select an option

Save mohayonao/30c4135107a32da8038080b21ce4f738 to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0.0, 1.0, 1000)
y = np.sin(x * np.pi * 2)
plt.figure(figsize=(18, 3))
plt.subplot(141)
plt.title("sine", fontsize=18)
plt.xticks([])
plt.yticks([])
plt.ylim(-1.1, +1.1)
plt.plot(y, linewidth=2)
y = 2 * x
y[y > 1] -= 2
plt.subplot(142)
plt.title("sawtooth", fontsize=18)
plt.xticks([])
plt.yticks([])
plt.ylim(-1.1, +1.1)
plt.plot(y, linewidth=2)
y[:500] = 1
y[500:] = -1
plt.subplot(143)
plt.title("square", fontsize=18)
plt.xticks([])
plt.yticks([])
plt.ylim(-1.1, +1.1)
plt.plot(y, linewidth=2)
y = x * 4
y[250:750] = 2 - y[250:750]
y[750:] = -4 + y[750:]
plt.subplot(144)
plt.title("triangle", fontsize=18)
plt.xticks([])
plt.yticks([])
plt.ylim(-1.1, +1.1)
plt.plot(y, linewidth=2)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment