# -*- coding: utf-8 -*-
\"\"\"
slider 3D numpy array
\"\"\"
import numpy
import pylab
from matplotlib.widgets import Slider
data = numpy.random.rand(100,256,256)
Try re-writing the update function as
def update(val):
frame = numpy.around(sframe.val)
l.set_data(data[frame,:,:])
so that you do not need to re-create all of the matplotlib objects every update
Seems like you need to cast frame number to int
def update(val):
frame = numpy.around(sframe.val)
l.set_data(data[int(frame),:,:])
otherwise it will throw an error:
l.set_data(data[frame,:,:])
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices