When that is available, that will probably be the best way to use nbagg. There is an IPython Widget version of nbagg that is currently a work in progress at the Matplotlib repository. It does block execution, though if you're interested in running a finite set of simulations and saving the results somewhere, it may not be a problem for you. It updates the data in the figure and does not redraw the whole figure every time. Here is an example that updates a plot in a loop. I want to achieve the same result, but more efficiently using nbagg. Here is some slightly modified code from the answer to the linked question above, which achieves this by re-drawing the whole figure every time. #Python jupyter notebook new plot updateSo the idea is to draw a plot and then, without any interaction from the user, update the data in the plot without destroying and re-creating the whole thing. To be clear what I'm asking for: what I want to do is to run some simulation code for a few iterations, then draw a plot of its current state, then run it for a few more iterations, then update the plot to reflect the current state, and so on. A pointer to any documentation on the topic would also be extremely helpful. Thus my question is, how does one efficiently update an existing plot in a Jupyter/Python notebook, using the nbagg backend? Since dynamically updating plots in matplotlib is a tricky issue in general, a simple working example would be an enormous help. #Python jupyter notebook new plot how toHowever, this wonderful new nbagg feature seems to be completely undocumented as far as I can tell, and I'm unable to find an example of how to use it to dynamically update a plot. Plot a 3D wireframe with data test data x, y, and z. Use the method, gettestdata to return a tuple X, Y, Z with a test dataset. axes.Axes to the figure as part of a subplot arrangement with nrow 1, ncols 1, index 1, and projection 3d. However, this works by destroying and re-creating the plot on every iteration, and a comment in one of the threads notes that this situation can be improved by using the new-ish %matplotlib nbagg magic, which provides an interactive figure embedded in the notebook, rather than a static image. Create a new figure, or activate an existing figure. In the answers to how to dynamically update a plot in a loop in ipython notebook (within one cell), an example is given of how to dynamically update a plot inside a Jupyter notebook within a Python loop.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |