Example #1
0
def plot_shifted(wave, shift=0.002, start=0.2):

    thinkplot.preplot(num=2)
    segment1 = wave.segment(start=start, duration=0.01)
    segment1.plot(linewidth=2, alpha=0.8)

    segment2 = wave.segment(start=start-shift, duration=0.01)
    segment2.plot(linewidth=2, alpha=0.4)

    corr = segment1.corr(segment2)
    text = r'$\rho =$ %.2g' % corr
    thinkplot.text(0.0005, -0.8, text)
Example #2
0
def plot_shifted(wave, offset=0.001, start=0.2):
    thinkplot.preplot(2)
    segment1 = wave.segment(start=start, duration=0.01)
    segment1.plot(linewidth=2, alpha=0.8)

    # start earlier and then shift times to line up
    segment2 = wave.segment(start=start-offset, duration=0.01)
    segment2.shift(offset)
    segment2.plot(linewidth=2, alpha=0.4)

    corr = segment1.corr(segment2)
    text = r'$\rho =$ %.2g' % corr
    thinkplot.text(segment1.start+0.0005, -0.8, text)
    thinkplot.config(xlabel='Time (s)', xlim=[start, start+duration], ylim=[-1, 1])
Example #3
0
def plot_shifted(wave, shift=0.002, start=0.2):
    """Plots two segments of a wave with different start times.

    wave: Wave
    shift: difference in start time (seconds)
    start: start time in seconds
    """
    thinkplot.preplot(num=2)
    segment1 = wave.segment(start=start, duration=0.01)
    segment1.plot(linewidth=2, alpha=0.8)

    segment2 = wave.segment(start=start - shift, duration=0.01)
    segment2.plot(linewidth=2, alpha=0.4)

    corr = segment1.corr(segment2)
    text = r'$\rho =$ %.2g' % corr
    thinkplot.text(0.0005, -0.8, text)
    thinkplot.config(xlabel='time (s)', ylim=[-1, 1])
def plot_shifted(wave, shift=0.002, start=0.2):
    """Plots two segments of a wave with different start times.

    wave: Wave
    shift: difference in start time (seconds)
    start: start time in seconds
    """
    thinkplot.preplot(num=2)
    segment1 = wave.segment(start=start, duration=0.01)
    segment1.plot(linewidth=2, alpha=0.8)

    segment2 = wave.segment(start=start-shift, duration=0.01)
    segment2.plot(linewidth=2, alpha=0.4)

    corr = segment1.corr(segment2)
    text = r'$\rho =$ %.2g' % corr
    thinkplot.text(0.0005, -0.8, text)
    thinkplot.config(xlabel='time (s)', ylim=[-1, 1])