Issue
Is there any plotting option in Python (IPython-Jupyter notebook) which accepts generators?
AFAIK matplotlib
doesn't support that. The only option I discovered is plot.ly with their Streaming API, but I would prefer not to use online solution due to big amount of data I need to plot in real-time.
Solution
A fixed length generator can always be converted to a list.
vals_list = list(vals_generator)
This should be appropriate input for matplotlib
.
Guessing from your updated information, it might be something like this:
from collections import deque
from matplotlib import pyplot
data_buffer = deque(maxlen=100)
for raw_data in data_stream:
data_buffer.append(arbitrary_convert_func(raw_data))
pyplot.plot(data_buffer)
Basically using a deque to have a fixed size buffer of data points.
Answered By - MisterMiyagi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.