#!/usr/bin/env python # coding: utf-8 # ## Image Browser # This example shows how to browse through a set of images with a slider. # In[ ]: get_ipython().run_line_magic('matplotlib', 'inline') import matplotlib.pyplot as plt # In[ ]: from IPython.html.widgets import interact # In[ ]: from sklearn import datasets # We will use the digits dataset from [scikit-learn](http://scikit-learn.org/stable/). # In[ ]: digits = datasets.load_digits() # In[ ]: def browse_images(digits): n = len(digits.images) def view_image(i): plt.imshow(digits.images[i], cmap=plt.cm.gray_r, interpolation='nearest') plt.title('Training: %s' % digits.target[i]) plt.show() interact(view_image, i=(0,n-1)) # In[ ]: browse_images(digits)