issues: 349026158
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
349026158 | MDU6SXNzdWUzNDkwMjYxNTg= | 2355 | Animated plots - a suggestion for implementation | 35968931 | closed | 0 | 9 | 2018-08-09T08:23:17Z | 2020-08-16T08:07:12Z | 2020-08-16T08:07:12Z | MEMBER | It'd be awesome if one could animate the plots xarray creates using matplotlib just by specifying the dimension over which to animate the plot. This would allow for rapid visualisation of time-evolving data and could potentially be very powerful (imagine a grid of faceted 2d plots, all evolving together over time). I know that there are already some libraries which can create animated plots of xarray data (e.g. Holoviews), but I think that it's within xarray's scope (#2030) to add another dimension to its default matplotlib-style plotting capabilities. How? I saw this new package for making it easier to animate matplotlib plots using the funcanimation module: animatplot. It essentially works by wrapping matplotlib commands like ```python import animatplot as amp import matplotlib.pyplot as plt X, Y = load_data_somehow block = amp.blocks.Line(X, Y) anim = amp.Animation([block]) anim.save_gif("animated_line") plt.show() ``` which creates a basic gif like this: I think that it might be possible to integrate this kind of animation-plotting tool by adding an optional dimension argument to xarray's plotting methods, which if given causes the function to call the wrapped animatplot plotting command instead of the bare matplotlib one. It would then return the corresponding "block" ready to be animated. Using the resulting code might only require a few lines to create an impressive visualisation: ```python turb2d = xr.load_dataset("turbulent_fluid_data.nc") block = turb2d["density"].plot.imshow(animate_over='time') anim = Animation([block]) anim.save_gif("fluid_density.gif") plt.show() ``` What would need changing? If we take the I wanted to ask about this before delving into the code too much or submitting a pull request, in case there is some problem with the idea. What do you think? |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/2355/reactions", "total_count": 1, "+1": 1, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |