I receive a bunch of live data from microphones. The length of a data set is 4000 and I receive it 5 times per second.
I use python2.7 and matplotlib. To get the idea of the data sets:
If its quiet
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -2, 0, -1, 0, 0, 0, -1, 1, -2, 0, -2, -2, -8, -1, -1, 0, -2, -1, -2, -1, -1, -1, 0, -1, 0, -1, 0, -1, -1, -1, -1, -1, 0, -1, 0, -1, -1, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, -1,-1, 0, -1, -4, -1, 0, -1, 2, -1, 0, 2, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, ...]
If its loud:
[-372, -37, -157, -143, 93, -212, 304, -225, 432, -177, 450, -79, 351, 40, 159, 147, -77, 213, -296, 222, -440, 173, -467, 77, -366, -41, -161, -147, 90, -215, 308, -225, 435, -175, 446, -77, 351, 42, 167, 147, -70, 210, -296, -166, 456, -76, 374, 34, ...]
My python script:
def plot_data(data):
x = [i for i in range(0, 4000)]
plt.plot(x,data.data)
plt.show()
def listener():
rospy.init_node('listener', anonymous=True)
rospy.Subscriber('/miro/rob01/platform/mics', platform_mics, show_data)
rospy.spin()
if __name__ == '__main__':
listener()
I'd like to plot the data and redraw or update every time I get a new data object. Need a continuous update of the graph.
The graph should look like this:
Do you know a good way to do so?