Created
March 16, 2017 18:11
-
-
Save alivcor/125f6b87c14eaedb5548d2079344bf6e to your computer and use it in GitHub Desktop.
Updating A Plot in Matplotlib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Bonus: If you want to handle events on keypress: | |
#http://matplotlib.org/examples/event_handling/keypress_demo.html | |
#Inspired by cnn_train in MatConvNet ?? :p (Please ignore if you do not understand - you're not supposed to !) | |
import math | |
import matplotlib.pyplot as plt | |
import numpy as np | |
# + | |
# | | |
# | | |
# | | |
# |XX | |
# | XX | |
# | XX | |
# | XX | |
# | XX | |
# | XXX | |
# | XX | |
# | XX | |
# | XXXX | |
# | XXXX | |
# | XXX | |
# | XXX | |
# | XXXX | |
# | XX | |
# | XXXX | |
# | XX | |
# | XXX | |
# | XX | |
# | XXX | |
# +---------------------------------------------------------------+ | |
x_vals = [] | |
y_vals = [] | |
plt.ion() | |
for i in xrange(10): | |
y_val = math.pow(2, 10-i) | |
x_val = i | |
x_vals.append(x_val) | |
y_vals.append(y_val) | |
plt.plot(np.array(x_vals), np.array(y_vals), marker='o', linestyle='--', color='r') | |
plt.pause(0.8) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment