Skip to content

Instantly share code, notes, and snippets.

@daviddoria
Created September 18, 2015 11:13
Show Gist options
  • Save daviddoria/027b5c158b6f200527a4 to your computer and use it in GitHub Desktop.
Save daviddoria/027b5c158b6f200527a4 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy
hl, = plt.plot([], [])
#plt.show()
def update_line(hl, new_data):
hl.set_xdata(numpy.append(hl.get_xdata(), new_data))
hl.set_ydata(numpy.append(hl.get_ydata(), new_data))
#ax.relim()
#ax.autoscale_view()
plt.draw()
arrayLen = 10
data = numpy.random.rand(arrayLen) # zero-based indexing
update_line(hl, data)
while True:
ind = numpy.random.randint(0,arrayLen-1)
data[ind] = data[ind] + 1
print data
update_line(hl, data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment