示例#1
0
文件: ephyview.py 项目: rossant/spiky
    
    zoom = nav.sx
    box = nav.get_viewbox()
    xlim = ((box[0] + 1) / 2. * (duration_initial), (box[2] + 1) / 2. * (duration_initial))
    xlimex, slice = get_view(data.shape[0], xlim, freq)
    
    # Paging system.
    dur = xlim[1] - xlim[0]
    index = int(np.floor(xlim[0] / dur))
    zoom_index = int(np.round(duration_initial / dur))
    i = (index, zoom_index)
    global SLICE
    if i != SLICE:
        SLICE = i
        updater.update(data, xlimex, slice)
    if updater.info:
        figure.set_data(**updater.info)
        updater.info.clear()
    
plt.animate(anim, dt=.01)
plt.action('Wheel', change_channel_height, key_modifier='Control',
           param_getter=lambda p: p['wheel'] * .001)
plt.action('Wheel', pan, key_modifier='Shift',
           param_getter=lambda p: (p['wheel'] * .002, 0))
plt.action('DoubleClick', 'ResetZoom')

plt.xlim(0., duration_initial)

plt.show()
f.close()
示例#2
0
# Animation weights for each disc, smaller = slower movement.
w = np.linspace(0.01, 0.1, n).reshape((-1, 1))

# Vertical lines with chromatic and major scales.
line_color = np.ones((50, 4)) * .5
scale = np.array([0, 2, 4, 5, 7, 9, 11])
scale = np.concatenate((scale, scale + 12, [24]))
scale = np.concatenate((2 * scale, 2 * scale + 1))
line_color[scale] = .75
plt.plot(np.repeat(np.linspace(-1., 1., 25), 2),
         np.tile([-1., 1.], 25), 
         color=line_color,
         primitive_type='LINES',
         is_static=True)

plt.xlim(-1.05, 1.05)

# EVENTS
# ------
hsv = np.ones((1, 3))

def update(fig, param, quantize=False):
    # Update the mouse position.
    global mouse
    mouse[0,:] = param['mouse_position']
    x, y = param['mouse_position']
    # Compensate for xlim.
    x = x * 1.05
    # Quantization on chromatic scale if click.
    if quantize:
        x = np.round(x * 12) / 12.
示例#3
0
        
        zoom = nav.sx
        box = nav.get_viewbox()
        xlim = ((box[0] + 1) / 2. * (duration_initial), (box[2] + 1) / 2. * (duration_initial))
        xlimex, slice = get_view(data.shape[0], xlim, freq)
        
        # Paging system.
        dur = xlim[1] - xlim[0]
        index = int(np.floor(xlim[0] / dur))
        zoom_index = int(np.round(duration_initial / dur))
        i = (index, zoom_index)
        global SLICE
        if i != SLICE:
            SLICE = i
            updater.update(data, xlimex, slice)
        if updater.info:
            figure.set_data(**updater.info)
            updater.info.clear()
        
    plt.animate(anim, dt=.01)
    plt.action('Wheel', change_channel_height, key_modifier='Control',
               param_getter=lambda p: p['wheel'] * .001)
    plt.action('Wheel', pan, key_modifier='Shift',
               param_getter=lambda p: (p['wheel'] * .002, 0))
    plt.action('DoubleClick', 'ResetZoom')

    plt.xlim(0., duration_initial)

    plt.show()
    # f.close()