r/IPython • u/nmiculinic • Jan 01 '16
How to have dynamically updating plot in IPython notebook?
I have code which dynamically generates new data points as time progresses. It takes for computing those data points and I would like to refresh the matplotlib plot dynamically in ipython notebook.. Following code best describes my attempt is achieving this functionality. The repository contains all necessary classes need for proper functioning.
Furthermore I'd appreciate general advice how to better make my visualizations, since matplotlib looks awkward in this example. Legend is placed over the plot and I'm unable to make plot larger.
7
Upvotes
1
u/Thors_Son Jan 01 '16
You need to use %matplotlib qt to create the external window, since I do not believe dynamic plot updating is supported inline.
The basic idea is to grab the axis object, then only remove the most recent "line" object, and make the system wait (otherwise it will be too fast to see the update) and then draw the new line, iterating.
There's an implementation in this repo with an included example notebook.
For good looks, I would Google "Seaborn", and then just import that for starters. Other than that, find a type of plot you need, and search for answers on how to make specific components you need for that. It takes forever but with practice you can make some pretty fantastic looking plots.