Skip to content

Instantly share code, notes, and snippets.

@aconz2
Created September 17, 2015 17:50
Show Gist options
  • Save aconz2/c650990b060cabd4c1c2 to your computer and use it in GitHub Desktop.
Save aconz2/c650990b060cabd4c1c2 to your computer and use it in GitHub Desktop.
Iterate through a series of matplotlib plots, waiting for keyboard input (from the terminal)
import numpy as np
from matplotlib import pyplot as plt
plt.ion()
# say you have a bunch of distributions you'd like to look at
data_sets = [np.random.poisson(lam, size=100), for lam in np.random.randint(1, 100, size=10)]
# in a REPL, this one-liner makes it easy to plot each one successively waiting for ENTER from the terminal
_ = [[plt.hist(data), input()] for data in data_sets]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment