None
Métodos potenciales de prospección, FCAG, 2023.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider, Button
#%matplotlib notebook
#%matplotlib inline
plt.xkcd()
plt.rcParams.update({'font.size': 14}) # tamaño de fuente
f0 = 1.0;
T = 1.0/f0
tmax = 11*T
dt1 = T/20 # [s]
dt2 = T/2
t1 = np.arange(0.0, tmax, dt1)
t2 = np.arange(0.0, tmax, dt2)
s1 = np.cos(2*np.pi*f0*t1) # senal
s2 = np.cos(2*np.pi*f0*t2) # senal
fig,ax = plt.subplots(1,1)
plt.subplots_adjust(bottom=0.28)
ax.axis([0, tmax-1, -1.5, +1.5])
ax.axis([0, tmax-1, -1.5, 1.5])
ax.set_xlabel('Tiempo (s)')
ax.set_ylabel('Amplitud')
axcolor = 'lightgoldenrodyellow'
#axcolor = 'lightgray'
axfreq = plt.axes([0.2, 0.1, 0.6, 0.03])
sfreq = Slider(axfreq, '$\Delta t$ (s)', T/10, T, valinit=T/2)
senal = ax.plot(t1,s1, color='gray',linewidth=4)
senal_muestreada, = ax.plot(t2,s2,color='royalblue',marker='o',linewidth=2,markersize=10)
def update(val):
dt = sfreq.val
# update time
t2=np.arange(0.0, tmax, dt)
senal_muestreada.set_xdata(t2)
# update signal
senal_muestreada.set_ydata(np.cos(2*np.pi*f0*t2))
fig.canvas.draw_idle()
sfreq.on_changed(update)
resetax = plt.axes([0.8, 0.025, 0.1, 0.04])
button = Button(resetax, 'Inicio', color=axcolor, hovercolor='0.975')
def reset(event):
sfreq.reset()
# do not indent
button.on_clicked(reset)
plt.show()
Eso es todo por hoy.