In [1]:
import numpy as np
twopi = 2 * np.pi
n = 2
A = 2
w = twopi / 10
k = twopi / 200
phi = np.deg2rad(180)
t = np.arange(0, 10 * n, 0.01)
y = A * np.cos(w * t - k * 0 + phi)
In [2]:
%matplotlib inline
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(8, 4))
ax.plot(t, y, linewidth='2', color='#006633')
ax.set_frame_on(False)
ax.axis([-0.1, 20.1, -3, 3])
ax.get_xaxis().set_ticks([])
ax.get_yaxis().set_ticks([])
# Box.
kw = dict(linestyle='--', color='grey', zorder=90)
ax.axhline(y=2, xmin=0.15, xmax=0.85, **kw)
ax.axhline(y=-2, xmin=0.15, xmax=0.85, **kw)
ax.axvline(x=5, ymin=-0.15, ymax=1.85, **kw)
ax.axvline(x=15, ymin=-0.15, ymax=1.85, **kw)
# Zero line.
_ = ax.annotate('', xy=(20, 0), xycoords='data',
xytext=(0, 0), textcoords='data',
arrowprops=dict(arrowstyle='->', color='black'))
# Arrow commom properties.
arrowprops = dict(arrowstyle='<->', color='black')
# Wave period (or length).
_ = ax.annotate('', xy=(15, 2.5), xycoords='data',
xytext=(5, 2.5), textcoords='data',
arrowprops=arrowprops)
# Amplitude.
_ = ax.annotate('', xy=(5, 2), xycoords='data',
xytext=(5, 0), textcoords='data',
arrowprops=arrowprops)
# Height.
ax.annotate('', xy=(15, 2), xycoords='data',
xytext=(15, -2), textcoords='data',
arrowprops=arrowprops)
# Angle.
_ = ax.annotate('', xy=(15, 2), xycoords='data',
xytext=(5, -2), textcoords='data',
arrowprops=arrowprops)
fig.savefig("esquema_ondas_branco.png", transparent=True)