In [ ]:
import numpy as np
twopi = 2 * np.pi
n = 2 # Duas ondas.
A = 2 # Amplitude = 2 metros.
w = twopi / 10 # T = 10 segundos.
k = twopi / 200 # lambda = 200 metros.
phi = np.deg2rad(180) # Fase [rad]
t = np.arange(0, 10 * n, 0.01) # Vetor tempo [s]
y = A * np.cos(w * t - k * 0 + phi) # Um ponto do oceano.
In [ ]:
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='->', facecolor='black'))
_ = ax.annotate(u'Espaço', xy=(20, 0), xycoords='data',
xytext=(20, 0.05), textcoords='data',
va='bottom', ha='right', color='blue')
_ = ax.annotate('Tempo', xy=(20, 0), xycoords='data',
xytext=(20, -0.05), textcoords='data',
va='top', ha='right', color='red')
# Arrow commom properties.
arrowprops = dict(arrowstyle='<->', facecolor='black')
# Wave period (or length).
_ = ax.annotate('', xy=(15, 2.5), xycoords='data',
xytext=(5, 2.5), textcoords='data',
arrowprops=arrowprops)
_ = ax.annotate(u'Comprimento', xy=(10, 2.5), xycoords='data',
xytext=(10, 2.55), textcoords='data',
va='bottom', ha='center', color='blue')
_ = ax.annotate(u'Período', xy=(10, 2.5), xycoords='data',
xytext=(10, 2.45), textcoords='data',
va='top', ha='center', color='red')
# Amplitude.
_ = ax.annotate('', xy=(5, 2), xycoords='data',
xytext=(5, 0), textcoords='data',
arrowprops=arrowprops)
_ = ax.annotate('Amplitude', xy=(5, 1), xycoords='data',
xytext=(4.9, 1), textcoords='data',
va='center', ha='right', rotation=90)
# Height.
ax.annotate('', xy=(15, 2), xycoords='data',
xytext=(15, -2), textcoords='data',
arrowprops=arrowprops)
_ = ax.annotate('Altura', xy=(15, 1), xycoords='data',
xytext=(14.9, 0.1), textcoords='data',
va='bottom', ha='right', rotation=90)
# Angle.
_ = ax.annotate('', xy=(15, 2), xycoords='data',
xytext=(5, -2), textcoords='data',
arrowprops=arrowprops)
_ = ax.annotate(u'Inclinação', xy=(10, 0), xycoords='data',
xytext=(10.5, 0.5), textcoords='data',
va='center', ha='center', rotation=35)